OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_ |
| 6 #define CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/run_loop.h" |
| 11 #include "chrome/browser/instant/instant_controller.h" |
| 12 #include "chrome/browser/instant/instant_model_observer.h" |
| 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_instant_controller.h" |
| 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 17 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 18 #include "chrome/common/search_types.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" |
| 20 |
| 21 class InstantTestModelObserver : public InstantModelObserver { |
| 22 public: |
| 23 InstantTestModelObserver(const InstantModel* model, |
| 24 chrome::search::Mode::Type desired_mode_type); |
| 25 ~InstantTestModelObserver(); |
| 26 |
| 27 void WaitUntilDesiredPreviewState(); |
| 28 |
| 29 // Overridden from InstantModelObserver: |
| 30 virtual void PreviewStateChanged(const InstantModel& model) OVERRIDE; |
| 31 |
| 32 private: |
| 33 const InstantModel* const model_; |
| 34 const chrome::search::Mode::Type desired_mode_type_; |
| 35 base::RunLoop run_loop_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver); |
| 38 }; |
| 39 |
| 40 class InstantTestBase : public InProcessBrowserTest { |
| 41 protected: |
| 42 void SetupInstant(); |
| 43 void SetupInstantUsingTemplateURL(); |
| 44 |
| 45 InstantController* instant() { |
| 46 return browser()->instant_controller()->instant(); |
| 47 } |
| 48 |
| 49 OmniboxView* omnibox() { |
| 50 return browser()->window()->GetLocationBar()->GetLocationEntry(); |
| 51 } |
| 52 |
| 53 void KillInstantRenderView(); |
| 54 |
| 55 void FocusOmnibox(); |
| 56 void FocusOmniboxAndWaitForInstantSupport(); |
| 57 |
| 58 void SetOmniboxText(const std::string& text); |
| 59 void SetOmniboxTextAndWaitForInstantToShow(const std::string& text); |
| 60 |
| 61 bool GetBoolFromJS(content::WebContents* contents, |
| 62 const std::string& script, |
| 63 bool* result) WARN_UNUSED_RESULT; |
| 64 bool GetIntFromJS(content::WebContents* contents, |
| 65 const std::string& script, |
| 66 int* result) WARN_UNUSED_RESULT; |
| 67 bool GetStringFromJS(content::WebContents* contents, |
| 68 const std::string& script, |
| 69 std::string* result) WARN_UNUSED_RESULT; |
| 70 bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT; |
| 71 bool CheckVisibilityIs(content::WebContents* contents, |
| 72 bool expected) WARN_UNUSED_RESULT; |
| 73 |
| 74 GURL instant_url_; |
| 75 }; |
| 76 |
| 77 #endif // CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_ |
OLD | NEW |