Skip to main content
summaryrefslogtreecommitdiffstats
blob: 73b05bb57ae11831c943af44c9f6edc04f4d525e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************************************
 * Copyright (c) 2010 SAP AG, Walldorf.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     SAP AG - initial API and implementation
 *******************************************************************************/
package org.eclipse.platform.discovery.ui.test.comp.internal;

import static org.junit.Assert.assertEquals;

import org.eclipse.platform.discovery.ui.test.comp.internal.pageobjects.TextControlPageObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import abbot.swt.finder.generic.MultipleFoundException;
import abbot.swt.finder.generic.NotFoundException;

public class TextControlTest
{
	private TextControlPageObject textControl;

	@Before
	public void setUp()
	{
		textControl = new TextControlPageObject();
		textControl.open();
	}

	@After
	public void tearDown()
	{
		textControl.close();
	}

	@Test
	public void testTextIsRestoredWhenControlIsEnabled() throws NotFoundException, MultipleFoundException
	{
		final String testText = "12345_6789";
		textControl.enterText(testText);
		assertEquals("Unexpected text value", testText, textControl.get());
		assertEquals("Unexpected text in SWT text", testText, textControl.getDisplayedText());

		textControl.setEnabled(false);
		assertEquals("SWT text should be empty", "", textControl.getDisplayedText());
		assertEquals("Unexpected text value", "", textControl.get());

		textControl.setEnabled(true);
		assertEquals("Unexpected text value", testText, textControl.get());
		assertEquals("Unexpected text in SWT text", testText, textControl.getDisplayedText());
	}

	@Test
	public void testTextMessageAmongEnabledStates() throws NotFoundException, MultipleFoundException
	{
		final String message = "MyMessage";
		textControl.setMessage(message);
		textControl.focus();
		assertEquals("Unexpected message", message, textControl.getMessage());
		assertEquals("Unexpected text displayed", "", textControl.getDisplayedText());

		textControl.setEnabled(false);
		assertEquals("Unexpected message", "", textControl.getMessage());
		assertEquals("Unexpected text displayed", message, textControl.getDisplayedText());

		textControl.setEnabled(true);
		assertEquals("Unexpected message", message, textControl.getMessage());
		assertEquals("Unexpected text displayed", "", textControl.getDisplayedText());
	}
}

Back to the top