@Test // (Test Cases for 1.8) test case 6 public void testNtNumericCacheSizeOKPressed() throws Exception { Utility.createProject(Messages.projCache); SWTBotShell propShell = Utility.selCacheUsingCnxtMenu(Messages.projCache, Messages.role1); wabot.checkBox().select(); // Cache size = alphabet // typeText and setting focus on OK is IMP. wabot.textWithLabel(Messages.cachScaleLbl).setText(""); wabot.textWithLabel(Messages.cachScaleLbl).typeText("ab"); wabot.button("OK").setFocus(); wabot.button("OK").click(); SWTBotShell errorShell = wabot.shell(Messages.cachPerErrTtl).activate(); Boolean alphabtErr = errorShell.getText().equals(Messages.cachPerErrTtl); wabot.button("OK").click(); // Cache size = special character wabot.textWithLabel(Messages.cachScaleLbl).setText(""); wabot.textWithLabel(Messages.cachScaleLbl).typeText("#*"); wabot.button("OK").setFocus(); wabot.button("OK").click(); errorShell = wabot.shell(Messages.cachPerErrTtl).activate(); Boolean splCharErr = errorShell.getText().equals(Messages.cachPerErrTtl); wabot.button("OK").click(); assertTrue("testNtNumericCacheSizeOKPressed", alphabtErr && splCharErr); propShell.close(); }
@Test // (Test Cases for 1.8) test case 4 public void testInvalidCacheSizeOKPressed() throws Exception { Utility.createProject(Messages.projCache); SWTBotShell propShell = Utility.selCacheUsingCnxtMenu(Messages.projCache, Messages.role1); wabot.checkBox().select(); // Cache size = 0 // typeText and setting focus on OK is IMP. wabot.textWithLabel(Messages.cachScaleLbl).setText(""); wabot.textWithLabel(Messages.cachScaleLbl).typeText("0"); wabot.button("OK").setFocus(); wabot.button("OK").click(); SWTBotShell errorShell = wabot.shell(Messages.cachPerErrTtl).activate(); Boolean zeroErr = errorShell.getText().equals(Messages.cachPerErrTtl); wabot.button("OK").click(); // Cache size < 0 i.e. Negative wabot.textWithLabel(Messages.cachScaleLbl).setText(""); wabot.textWithLabel(Messages.cachScaleLbl).typeText("-2"); wabot.button("OK").setFocus(); wabot.button("OK").click(); errorShell = wabot.shell(Messages.cachPerErrTtl).activate(); Boolean negErr = errorShell.getText().equals(Messages.cachPerErrTtl); wabot.button("OK").click(); // Cache size > 100 wabot.textWithLabel(Messages.cachScaleLbl).setText(""); wabot.textWithLabel(Messages.cachScaleLbl).typeText("105%"); wabot.button("OK").setFocus(); wabot.button("OK").click(); errorShell = wabot.shell(Messages.cachPerErrTtl).activate(); Boolean grtErr = errorShell.getText().equals(Messages.cachPerErrTtl); wabot.button("OK").click(); assertTrue("testInvalidCacheSizeOKPressed", zeroErr && negErr && grtErr); propShell.close(); }
@Override public void confirmShellAddProjectUsingExistProject(String projectName) throws RemoteException { SWTBot bot = new SWTBot(); bot.waitUntil( Conditions.shellIsActive(SHELL_ADD_PROJECT), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT); SWTBotShell shell = bot.shell(SHELL_ADD_PROJECT); shell.activate(); shell.bot().radio(RADIO_USING_EXISTING_PROJECT).click(); shell.bot().textWithLabel("Project name", 1).setText(projectName); shell.bot().button(FINISH).click(); // prevent STF from entering an endless loop int timeout = 5; confirmDialogs: while (timeout-- > 0) { bot.sleep(2000); for (SWTBotShell currentShell : bot.shells()) { if (currentShell.getText().equals(SHELL_WARNING_LOCAL_CHANGES_DELETED) || currentShell.getText().equals(SHELL_SAVE_RESOURCE)) { currentShell.activate(); currentShell.bot().button(YES).click(); currentShell.bot().waitUntil(Conditions.shellCloses(currentShell)); break confirmDialogs; } else if (currentShell.getText().equals(SHELL_CONFIRM_SAVE_UNCHANGED_CHANGES)) { currentShell.activate(); currentShell.bot().button(YES).click(); currentShell.bot().waitUntil(Conditions.shellCloses(currentShell)); shell.bot().button(FINISH).click(); continue confirmDialogs; } } } shell.bot().waitUntil(Conditions.shellCloses(shell)); }
@Test // (Test Cases for 1.8) test case 5 public void testInvalidCacheSizeOKToLeave() throws Exception { Utility.createProject(Messages.projCache); SWTBotShell propShell = Utility.selCacheUsingCnxtMenu(Messages.projCache, Messages.role1); wabot.checkBox().select(); /* * To avoid missing storage account error, * type some value. Requires typeText only. */ wabot.textWithLabel(Messages.keyLbl).typeText("a"); wabot.textWithLabel(Messages.nameLbl).typeText("a"); // Cache size = 0 wabot.textWithLabel(Messages.cachScaleLbl).setText(""); wabot.textWithLabel(Messages.cachScaleLbl).typeText("0"); SWTBotTree properties = propShell.bot().tree(); properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select(); SWTBotShell errorShell = wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate(); Boolean zeroErr = errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " ")); wabot.button("OK").click(); // Cache size < 0 i.e. Negative wabot.textWithLabel(Messages.cachScaleLbl).setText(""); wabot.textWithLabel(Messages.cachScaleLbl).typeText("-2"); properties = propShell.bot().tree(); properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select(); errorShell = wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate(); Boolean negErr = errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " ")); wabot.button("OK").click(); // Cache size > 100 wabot.textWithLabel(Messages.cachScaleLbl).setText(""); wabot.textWithLabel(Messages.cachScaleLbl).typeText("105%"); properties = propShell.bot().tree(); properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select(); errorShell = wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate(); Boolean grtErr = errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " ")); wabot.button("OK").click(); assertTrue("testInvalidCacheSizeOKToLeave", zeroErr && negErr && grtErr); propShell.close(); }
public static void init(String projectName) throws Exception { SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; Utilities.getDefault().buildProject(projectName); bot = new SWTBot(); SWTBotShell executableShell = null; for (int i = 0, attempts = 100; i < attempts; i++) { for (SWTBotShell shell : bot.shells()) { if (shell.getText().contains("Debug New Executable")) { executableShell = shell; shell.setFocus(); break; } } if (executableShell != null) break; bot.sleep(10); } IPath executablePath = Utilities.getDefault().getProjectPath(projectName).append("a.out"); // $NON-NLS-1$ executableShell.bot().textWithLabel("Binary: ").typeText(executablePath.toOSString()); bot.sleep(2000); executableShell.bot().button("OK").click(); mainShell = null; for (int i = 0, attempts = 100; i < attempts; i++) { for (SWTBotShell shell : bot.shells()) { if (shell.getText().contains("C/C++ Stand-alone Debugger")) { mainShell = shell; shell.setFocus(); break; } } if (mainShell != null) break; bot.sleep(10); } assertNotNull(mainShell); }
@Override public void confirmShellAddContact(JID jid) throws RemoteException { SWTBot bot = new SWTBot(); SWTBotShell shell = bot.shell(SHELL_ADD_CONTACT_WIZARD); shell.activate(); shell.bot().comboBoxWithLabel(LABEL_XMPP_JABBER_ID).setText(jid.getBase()); shell.bot().button(FINISH).click(); bot.sleep(500); for (SWTBotShell currentShell : bot.shells()) { // FIXME HARDCODED ! if (currentShell.getText().equals("Contact Unknown")) { currentShell.bot().button(YES).click(); break; } } bot.waitUntil(Conditions.shellCloses(shell)); // wait for tree update in the saros session view bot.sleep(500); }