/* * This method can be used before a test starts to ensure DS is ready. * A possible place to call this might be Start_DSTest() * Not sure how robust to make this / if run before every test (top heavy). */ public boolean verifyDSReady() { Pattern pProxy = new Pattern("DS_Preferences_Proxy_Titlebar.PNG").similar((float) 0.80); Pattern pCloseProxy = new Pattern(pProxy).targetOffset(230, -5); Pattern pSyncFolders = new Pattern("DS_Preferences_Synced_Folders_Titlebar.PNG").similar((float) 0.80); Pattern pCloseSyncFolders = new Pattern(pSyncFolders).targetOffset(225, -5); Pattern pPreferences = new Pattern("DS_Preferences_Titlebar.png").similar((float) 0.80); Pattern pClosePreference = new Pattern(pPreferences).targetOffset(235, -5); if (!DSReuse.checkTaskRunning("clouddrivew.exe")) { logThis("DS is NOT running, attempting to start it."); DSReuse.startDS(); if (DSReuse.checkTaskRunning("clouddrivew.exe")) { sikuliScreen.wait(10.0); if (verify_DS_Icon_Online_Synced()) { return true; } } else { logThis("Tried to launch DS and failed."); return false; } } else if (verify_DS_Icon_Online_Synced()) { logThis("DS is synced and ready to test."); return true; } else if (verify_DS_Icon_Paused()) { // This just covers the basics. Not all errors/windows are trapped for. // Similarity of 80% work for both window with or without focus (red x) logThis("DS is paused, attempting to get it running again..."); // Close Proxy window if open if (sikuliScreen.exists(pProxy) != null) { logThis("Preferences>Network>Proxy window open, attempting to close."); try { sikuliScreen.click(pCloseProxy); } catch (Exception e) { logThis("Tried to close Proxy window but failed. " + e.getMessage()); return false; } } // Close Sync Folder window if open if (sikuliScreen.exists(pSyncFolders) != null) { logThis("Preferences>Advanced>Sync Folders window open, attempting to close."); try { sikuliScreen.click(pCloseSyncFolders); } catch (Exception e) { logThis("Tried to close Syc Folders window but failed. " + e.getMessage()); return false; } } // Close Preferences Window if open. if (sikuliScreen.exists(pPreferences) != null) { logThis("Preferences window was open, closing it."); try { sikuliScreen.click(pClosePreference); if (verify_DS_Icon_Online_Synced()) { return true; } } catch (Exception e) { logThis("Tried to close Preferences window but failed. " + e.getMessage()); return false; } } else { // Resume try { access_DSMenu(); menu_Resume(); sikuliScreen.wait(5.0); if (verify_DS_Icon_Online_Synced()) { return true; } } catch (Exception e) { logThis("Tried to 'Resume' DS but failed. " + e.getMessage()); return false; } } } else if (verify_DS_Icon_Online_Syncing()) { // Decided against using ds_Wait_Sync_Start() // Didn't want to fail test before it starts, and how long do you wait? logThis("WARNING: DS is currently syncing and may produce endesireable test results."); return true; } else if (verify_DS_Icon_Offline()) { try { sign_In_If_Signed_Out(); sikuliScreen.wait(10.0); if (sikuliScreen.exists(pPreferences) != null) { sikuliScreen.click(pClosePreference); } if (verify_DS_Icon_Online_Synced()) { return true; } } catch (Exception e) { logThis("Attempt to log into DS failed. " + e.getMessage()); return false; } } else { logThis("WARNING: DS may not be ready, fell through logic check."); } return false; }