Index: chrome/browser/instant/instant_test_utils.h |
diff --git a/chrome/browser/instant/instant_test_utils.h b/chrome/browser/instant/instant_test_utils.h |
index 7059ed269a9386569eeac3fac30019281ebf6e7c..1693544cafd590ab1ab5289a4df63f6dff721b9c 100644 |
--- a/chrome/browser/instant/instant_test_utils.h |
+++ b/chrome/browser/instant/instant_test_utils.h |
@@ -7,63 +7,77 @@ |
#include <string> |
+#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
#include "base/run_loop.h" |
-#include "chrome/browser/instant/instant_controller.h" |
#include "chrome/browser/instant/instant_model_observer.h" |
-#include "chrome/browser/ui/browser.h" |
-#include "chrome/browser/ui/browser_instant_controller.h" |
-#include "chrome/browser/ui/browser_window.h" |
-#include "chrome/browser/ui/omnibox/location_bar.h" |
-#include "chrome/browser/ui/omnibox/omnibox_view.h" |
-#include "chrome/common/search_types.h" |
-#include "chrome/test/base/in_process_browser_test.h" |
+#include "googleurl/src/gurl.h" |
+#include "net/test/test_server.h" |
+ |
+class Browser; |
+class InstantController; |
+class InstantModel; |
+class InstantService; |
+class OmniboxView; |
+struct TemplateURLData; |
+ |
+namespace content { |
+class WebContents; |
+} |
class InstantTestModelObserver : public InstantModelObserver { |
public: |
- InstantTestModelObserver(InstantModel* model, |
- chrome::search::Mode::Type desired_mode_type); |
- ~InstantTestModelObserver(); |
+ InstantTestModelObserver(InstantController* controller, |
+ const InstantModel* desired_model); |
+ virtual ~InstantTestModelObserver(); |
- void WaitUntilDesiredPreviewState(); |
+ void WaitForDesiredOverlayState(); |
+ private: |
// Overridden from InstantModelObserver: |
- virtual void PreviewStateChanged(const InstantModel& model) OVERRIDE; |
+ virtual void OverlayStateChanged(const InstantModel& model) OVERRIDE; |
- private: |
- InstantModel* const model_; |
- const chrome::search::Mode::Type desired_mode_type_; |
+ InstantController* const controller_; |
+ const InstantModel* const desired_model_; |
base::RunLoop run_loop_; |
DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver); |
}; |
-class InstantTestBase : public InProcessBrowserTest { |
+// This utility class is meant to be used in a "mix-in" fashion, giving the |
+// derived test class additional Instant-related functionality. |
+class InstantTestBase { |
public: |
- InstantTestBase() |
- : https_test_server_( |
- net::TestServer::TYPE_HTTPS, |
- net::BaseTestServer::SSLOptions(), |
- base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { |
- } |
- |
- protected: |
- void SetupInstant(); |
- |
- InstantController* instant() { |
- return browser()->instant_controller()->instant(); |
- } |
- |
- OmniboxView* omnibox() { |
- return browser()->window()->GetLocationBar()->GetLocationEntry(); |
- } |
- |
- void KillInstantRenderView(); |
+ InstantTestBase(); |
+ virtual ~InstantTestBase(); |
+ |
+ // Accessors for common objects. These objects are meant for use by derived |
+ // classes. InstantTestBase doesn't itself use them. |
+ net::TestServer* https_test_server() { return &https_test_server_; } |
+ const GURL& instant_url() const { return instant_url_; } |
+ void set_instant_url(const GURL& url) { instant_url_ = url; } |
+ void set_browser(Browser* browser) { browser_ = browser; } |
+ |
+ // Initializes the user profile dir so that Instant is disabled. Returns true |
+ // on success. Call this from InProcessBrowserTest::SetUpUserDataDirectory() |
+ // to ensure that Instant doesn't try to activate on browser startup. To |
+ // re-enable Instant later, call SetupDefaultSearchProvider(). |
+ bool DisableInstantOnStartup(); |
+ |
+ // Sets up the default search engine. NOTE: |template_data| must have a valid |
+ // Instant URL for this to work. In particular, InstantTestBase doesn't fill |
+ // it in using |instant_url_|. |
+ void SetupDefaultSearchProvider(const TemplateURLData& template_data); |
+ |
+ InstantService* service() const; |
+ InstantController* instant() const; |
+ OmniboxView* omnibox() const; |
void FocusOmnibox(); |
void FocusOmniboxAndWaitForInstantSupport(); |
void SetOmniboxText(const std::string& text); |
- void SetOmniboxTextAndWaitForInstantToShow(const std::string& text); |
+ void SetOmniboxTextAndWaitForOverlayToShow(const std::string& text); |
bool GetBoolFromJS(content::WebContents* contents, |
const std::string& script, |
@@ -74,16 +88,17 @@ class InstantTestBase : public InProcessBrowserTest { |
bool GetStringFromJS(content::WebContents* contents, |
const std::string& script, |
std::string* result) WARN_UNUSED_RESULT; |
- bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT; |
bool CheckVisibilityIs(content::WebContents* contents, |
bool expected) WARN_UNUSED_RESULT; |
- bool HasUserInputInProgress(); |
- bool HasTemporaryText(); |
- GURL instant_url_; |
+ void KillOverlayRenderView(); |
- // HTTPS Testing server, started on demand. |
+ private: |
net::TestServer https_test_server_; |
+ GURL instant_url_; |
+ Browser* browser_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InstantTestBase); |
}; |
#endif // CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_ |