| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_TEST_RELIABILITY_AUTOMATED_UI_TEST_BASE_H_ | |
| 6 #define CHROME_TEST_RELIABILITY_AUTOMATED_UI_TEST_BASE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "chrome/test/ui/ui_test.h" | |
| 11 | |
| 12 class WindowProxy; | |
| 13 | |
| 14 class AutomatedUITestBase : public UITest { | |
| 15 protected: | |
| 16 AutomatedUITestBase(); | |
| 17 virtual ~AutomatedUITestBase(); | |
| 18 | |
| 19 virtual void SetUp() OVERRIDE; | |
| 20 | |
| 21 virtual void LogErrorMessage(const std::string &error); | |
| 22 virtual void LogWarningMessage(const std::string &warning); | |
| 23 virtual void LogInfoMessage(const std::string &info); | |
| 24 | |
| 25 // Actions | |
| 26 | |
| 27 // NOTE: This list is sorted alphabetically. | |
| 28 // All functions are synchronous unless specified with Async. | |
| 29 | |
| 30 // Go back in active tab. | |
| 31 // Returns true if successful, false otherwise. | |
| 32 bool BackButton(); | |
| 33 | |
| 34 // Close the selected tab in the current browser window. The function will | |
| 35 // not try close the tab if it is the only tab of the last normal window, so | |
| 36 // the application is not got closed. | |
| 37 // Returns true if the tab is closed, false otherwise. | |
| 38 bool CloseActiveTab(); | |
| 39 | |
| 40 // Close the current browser window if it is not the only window left. | |
| 41 // (Closing the last window will get application closed.) | |
| 42 // Returns true if the window is closed, false otherwise. | |
| 43 bool CloseActiveWindow(); | |
| 44 | |
| 45 // Duplicates the current tab. | |
| 46 // Returns true if a duplicated tab is added. | |
| 47 bool DuplicateTab(); | |
| 48 | |
| 49 // Activates "find in page" on the current page. Returns true on success. | |
| 50 bool FindInPage(); | |
| 51 | |
| 52 // Go forward in active tab. | |
| 53 // Returns true if successful, false otherwise. | |
| 54 bool ForwardButton(); | |
| 55 | |
| 56 // Opens an OffTheRecord browser window. | |
| 57 bool GoOffTheRecord(); | |
| 58 | |
| 59 // Navigates to the Home page. | |
| 60 // Returns true if call to activate the accelerator is successful. | |
| 61 bool Home(); | |
| 62 | |
| 63 // Navigates the activate tab to given url. | |
| 64 bool Navigate(const GURL& url); | |
| 65 | |
| 66 // Opens a new tab in the active window using an accelerator. | |
| 67 // Returns true if a new tab is successfully opened. | |
| 68 bool NewTab(); | |
| 69 | |
| 70 // Opens a new browser window by calling automation()->OpenNewBrowserWindow. | |
| 71 // Then activates the tab opened in the new window. | |
| 72 // Returns true if window is successfully created. | |
| 73 // If optional parameter previous_browser is passed in, it is set to be the | |
| 74 // previous browser window when new window is successfully created, and the | |
| 75 // caller owns previous_browser. | |
| 76 bool OpenAndActivateNewBrowserWindow( | |
| 77 scoped_refptr<BrowserProxy>* previous_browser); | |
| 78 | |
| 79 // Reload the active tab. | |
| 80 // Returns true if successful, false otherwise. | |
| 81 bool ReloadPage(); | |
| 82 | |
| 83 // Restores a previously closed tab. | |
| 84 // Returns true if the tab is successfully restored. | |
| 85 bool RestoreTab(); | |
| 86 | |
| 87 // Activates the next tab on the active browser window. | |
| 88 // Returns true on success. | |
| 89 bool SelectNextTab(); | |
| 90 | |
| 91 // Activates the previous tab on the active browser window. | |
| 92 // Returns true on success. | |
| 93 bool SelectPreviousTab(); | |
| 94 | |
| 95 // Opens the Downloads page in the current active browser window. | |
| 96 // Returns true on success. | |
| 97 bool ShowDownloads(); | |
| 98 | |
| 99 // Opens the History page in the current active browser window. | |
| 100 // Returns true on success. | |
| 101 bool ShowHistory(); | |
| 102 | |
| 103 // Runs the specified browser command in the current active browser. | |
| 104 // See Browser::ExecuteCommandWithDisposition() for the list of commands. | |
| 105 // Returns true if the call is successfully dispatched. | |
| 106 // Possible failures include the active window is not a browser window or | |
| 107 // the message to apply the accelerator fails. | |
| 108 bool RunCommandAsync(int browser_command); | |
| 109 | |
| 110 // Runs the specified browser command in the current active browser, wait | |
| 111 // and return until the command has finished executing. | |
| 112 // See Browser::ExecuteCommandWithDisposition() for the list of commands. | |
| 113 // Returns true if the call is successfully dispatched and executed. | |
| 114 // Possible failures include the active window is not a browser window, or | |
| 115 // the message to apply the accelerator fails, or the command execution | |
| 116 // fails. | |
| 117 bool RunCommand(int browser_command); | |
| 118 | |
| 119 void set_active_browser(BrowserProxy* browser) { | |
| 120 active_browser_ = browser; | |
| 121 } | |
| 122 BrowserProxy* active_browser() const { return active_browser_.get(); } | |
| 123 | |
| 124 // Get the selected tab within the current active browser window, then | |
| 125 // create a corresponding TabProxy and transfer the ownership to caller. | |
| 126 // If success return the pointer to the newly created TabProxy and the | |
| 127 // caller owns the TabProxy. Return NULL otherwise. | |
| 128 scoped_refptr<TabProxy> GetActiveTab(); | |
| 129 | |
| 130 // Returns the WindowProxy associated with the given BrowserProxy | |
| 131 // (transferring ownership of the pointer to the caller) and brings that | |
| 132 // window to the top. | |
| 133 scoped_refptr<WindowProxy> GetAndActivateWindowForBrowser( | |
| 134 BrowserProxy* browser); | |
| 135 | |
| 136 private: | |
| 137 scoped_refptr<BrowserProxy> active_browser_; | |
| 138 | |
| 139 DISALLOW_COPY_AND_ASSIGN(AutomatedUITestBase); | |
| 140 }; | |
| 141 | |
| 142 #endif // CHROME_TEST_RELIABILITY_AUTOMATED_UI_TEST_BASE_H_ | |
| OLD | NEW |