| 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 e09d27603f62d623820707ea3ca73822118f864d..1c88d0b5887b9b32ed947e431946dc8c73b68516 100644
|
| --- a/chrome/browser/instant/instant_test_utils.h
|
| +++ b/chrome/browser/instant/instant_test_utils.h
|
| @@ -9,79 +9,60 @@
|
|
|
| #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_overlay_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/common/search_types.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 InstantOverlayModelObserver {
|
| - public:
|
| - InstantTestModelObserver(InstantOverlayModel* model,
|
| - chrome::search::Mode::Type desired_mode_type);
|
| - ~InstantTestModelObserver();
|
| -
|
| - void WaitForDesiredOverlayState();
|
| -
|
| - // Overridden from InstantOverlayModelObserver:
|
| - virtual void OverlayStateChanged(const InstantOverlayModel& model) OVERRIDE;
|
| -
|
| - private:
|
| - InstantOverlayModel* const model_;
|
| - const chrome::search::Mode::Type desired_mode_type_;
|
| - base::RunLoop run_loop_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver);
|
| -};
|
| +}
|
|
|
| // This utility class is meant to be used in a "mix-in" fashion, giving the
|
| // derived test class additional Instant-related functionality.
|
| class InstantTestBase {
|
| - protected:
|
| - InstantTestBase()
|
| - : https_test_server_(
|
| - net::TestServer::TYPE_HTTPS,
|
| - net::BaseTestServer::SSLOptions(),
|
| - base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {
|
| - }
|
| - virtual ~InstantTestBase() {}
|
| -
|
| - protected:
|
| - void SetupInstant(Browser* browser);
|
| - void Init(const GURL& instant_url);
|
| -
|
| - InstantController* instant() {
|
| - return browser_->instant_controller()->instant();
|
| - }
|
| -
|
| - OmniboxView* omnibox() {
|
| - return browser_->window()->GetLocationBar()->GetLocationEntry();
|
| - }
|
| + public:
|
| + 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; }
|
| +
|
| + // Call this as soon as possible. It's used by many of the other methods in
|
| + // this class, including SetupDefaultSearchProvider() and instant(). If you
|
| + // create a new browser window and want those other methods to point to it,
|
| + // call set_browser() first with the new Browser object.
|
| + void set_browser(Browser* browser) { browser_ = browser; }
|
|
|
| - net::TestServer& https_test_server() { return https_test_server_; }
|
| + // 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();
|
|
|
| - void KillInstantRenderView();
|
| + // 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 WaitForInstantSupport();
|
| void FocusOmniboxAndWaitForInstantSupport();
|
| - void FocusOmniboxAndWaitForInstantExtendedSupport();
|
|
|
| void SetOmniboxText(const std::string& text);
|
| + void WaitForOverlayToShow();
|
| + void WaitForOverlayToHide();
|
| void SetOmniboxTextAndWaitForOverlayToShow(const std::string& text);
|
|
|
| bool GetBoolFromJS(content::WebContents* contents,
|
| @@ -93,27 +74,23 @@ class InstantTestBase {
|
| 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();
|
|
|
| - // Loads a named image from url |image| from the given |rvh| host. |loaded|
|
| - // returns whether the image was able to load without error.
|
| - // The method returns true if the JavaScript executed cleanly.
|
| - bool LoadImage(content::RenderViewHost* rvh,
|
| - const std::string& image,
|
| - bool* loaded);
|
| + void KillOverlayRenderView();
|
| +
|
| + // Loads |image_url| in the context of |contents|. |loaded| contains whether
|
| + // the image was able to load without error. The method returns true if the
|
| + // JavaScript executed cleanly.
|
| + bool LoadImage(content::WebContents* contents,
|
| + const std::string& image_url,
|
| + bool* loaded) WARN_UNUSED_RESULT;
|
|
|
| private:
|
| + net::TestServer https_test_server_;
|
| GURL instant_url_;
|
| -
|
| Browser* browser_;
|
|
|
| - // HTTPS Testing server, started on demand.
|
| - net::TestServer https_test_server_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(InstantTestBase);
|
| };
|
|
|
|
|