blob: 57117080a42c5526e7ab5f78961683bd3c79e78b (
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
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*******************************************************************************
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2010, Ketan Padegaonkar <KetanPadegaonkar@gmail.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.egit.ui.common;
import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertEnabled;
import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertNotEnabled;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withText;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
public class RepoRemoteBranchesPage {
private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
public void assertRemoteBranches(String... branches) {
SWTBotTree tree = bot.tree();
bot.waitUntil(widgetIsEnabled(tree), 20000);
for (String branch : branches) {
tree.getTreeItem(branch);
}
}
public void selectBranches(String... branches) {
SWTBotTree tree = bot.tree();
bot.waitUntil(widgetIsEnabled(tree));
for (String branch : branches) {
tree.getTreeItem(branch).check();
}
}
public WorkingCopyPage nextToWorkingCopy() {
bot.button("Next >").click();
return new WorkingCopyPage();
}
public void deselectAllBranches() {
SWTBotTree tree = bot.tree();
bot.waitUntil(widgetIsEnabled(tree), 60000);
SWTBotTreeItem[] items = tree.getAllItems();
for (int i = 0; i < items.length; i++) {
items[i].uncheck();
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void assertErrorMessage(String errorMessage) {
bot.waitUntil(
waitForWidget(allOf(widgetOfType(Text.class), withText(" "
+ errorMessage))), 20000);
}
public void assertNextIsDisabled() {
assertNotEnabled(bot.button("Next >"));
}
public void assertNextIsEnabled() {
assertEnabled(bot.button("Next >"));
}
public void assertCannotProceed() {
assertEnabled(bot.button("Cancel"));
assertEnabled(bot.button("< Back"));
assertNotEnabled(bot.button("Next >"));
assertNotEnabled(bot.button("Finish"));
}
public void cancel() {
bot.button("Cancel").click();
}
}
|