| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ |
| 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // This utility class is meant to be used in a "mix-in" fashion, giving the | 33 // This utility class is meant to be used in a "mix-in" fashion, giving the |
| 34 // derived test class additional Instant-related functionality. | 34 // derived test class additional Instant-related functionality. |
| 35 class InstantTestBase { | 35 class InstantTestBase { |
| 36 protected: | 36 protected: |
| 37 InstantTestBase(); | 37 InstantTestBase(); |
| 38 virtual ~InstantTestBase(); | 38 virtual ~InstantTestBase(); |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 void SetupInstant(Browser* browser); | 41 void SetupInstant(Browser* browser); |
| 42 void Init(const GURL& instant_url, const GURL& ntp_url, | 42 void Init(const GURL& instant_url, bool init_suggestions_url); |
| 43 bool init_suggestions_url); | |
| 44 | 43 |
| 45 void SetInstantURL(const std::string& url); | 44 void SetInstantURL(const std::string& url); |
| 46 | 45 |
| 47 void set_browser(Browser* browser) { | 46 void set_browser(Browser* browser) { |
| 48 browser_ = browser; | 47 browser_ = browser; |
| 49 } | 48 } |
| 50 | 49 |
| 51 BrowserInstantController* browser_instant() { | 50 BrowserInstantController* browser_instant() { |
| 52 return browser_->instant_controller(); | 51 return browser_->instant_controller(); |
| 53 } | 52 } |
| 54 | 53 |
| 55 InstantController* instant() { | 54 InstantController* instant() { |
| 56 return browser_->instant_controller()->instant(); | 55 return browser_->instant_controller()->instant(); |
| 57 } | 56 } |
| 58 | 57 |
| 59 OmniboxView* omnibox() { | 58 OmniboxView* omnibox() { |
| 60 return browser_->window()->GetLocationBar()->GetOmniboxView(); | 59 return browser_->window()->GetLocationBar()->GetOmniboxView(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 const GURL& instant_url() const { return instant_url_; } | 62 const GURL& instant_url() const { return instant_url_; } |
| 64 | 63 |
| 65 net::SpawnedTestServer& https_test_server() { return https_test_server_; } | 64 net::SpawnedTestServer& https_test_server() { return https_test_server_; } |
| 66 | 65 |
| 67 void KillInstantRenderView(); | 66 void KillInstantRenderView(); |
| 68 | 67 |
| 69 void FocusOmnibox(); | 68 void FocusOmnibox(); |
| 69 void FocusOmniboxAndWaitForInstantNTPSupport(); |
| 70 | 70 |
| 71 void SetOmniboxText(const std::string& text); | 71 void SetOmniboxText(const std::string& text); |
| 72 | 72 |
| 73 void PressEnterAndWaitForNavigation(); | 73 void PressEnterAndWaitForNavigation(); |
| 74 | 74 |
| 75 bool GetBoolFromJS(content::WebContents* contents, | 75 bool GetBoolFromJS(content::WebContents* contents, |
| 76 const std::string& script, | 76 const std::string& script, |
| 77 bool* result) WARN_UNUSED_RESULT; | 77 bool* result) WARN_UNUSED_RESULT; |
| 78 bool GetIntFromJS(content::WebContents* contents, | 78 bool GetIntFromJS(content::WebContents* contents, |
| 79 const std::string& script, | 79 const std::string& script, |
| 80 int* result) WARN_UNUSED_RESULT; | 80 int* result) WARN_UNUSED_RESULT; |
| 81 bool GetStringFromJS(content::WebContents* contents, | 81 bool GetStringFromJS(content::WebContents* contents, |
| 82 const std::string& script, | 82 const std::string& script, |
| 83 std::string* result) WARN_UNUSED_RESULT; | 83 std::string* result) WARN_UNUSED_RESULT; |
| 84 bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT; |
| 84 bool CheckVisibilityIs(content::WebContents* contents, | 85 bool CheckVisibilityIs(content::WebContents* contents, |
| 85 bool expected) WARN_UNUSED_RESULT; | 86 bool expected) WARN_UNUSED_RESULT; |
| 86 | 87 |
| 87 std::string GetOmniboxText(); | 88 std::string GetOmniboxText(); |
| 88 | 89 |
| 89 // Loads a named image from url |image| from the given |rvh| host. |loaded| | 90 // Loads a named image from url |image| from the given |rvh| host. |loaded| |
| 90 // returns whether the image was able to load without error. | 91 // returns whether the image was able to load without error. |
| 91 // The method returns true if the JavaScript executed cleanly. | 92 // The method returns true if the JavaScript executed cleanly. |
| 92 bool LoadImage(content::RenderViewHost* rvh, | 93 bool LoadImage(content::RenderViewHost* rvh, |
| 93 const std::string& image, | 94 const std::string& image, |
| 94 bool* loaded); | 95 bool* loaded); |
| 95 | 96 |
| 96 // Returns the omnibox's inline autocompletion (shown in blue highlight). | 97 // Returns the omnibox's inline autocompletion (shown in blue highlight). |
| 97 base::string16 GetBlueText(); | 98 base::string16 GetBlueText(); |
| 98 | 99 |
| 99 private: | 100 private: |
| 100 GURL instant_url_; | 101 GURL instant_url_; |
| 101 GURL ntp_url_; | |
| 102 | 102 |
| 103 Browser* browser_; | 103 Browser* browser_; |
| 104 | 104 |
| 105 // HTTPS Testing server, started on demand. | 105 // HTTPS Testing server, started on demand. |
| 106 net::SpawnedTestServer https_test_server_; | 106 net::SpawnedTestServer https_test_server_; |
| 107 | 107 |
| 108 // Set to true to initialize suggestions URL in default search provider. | 108 // Set to true to initialize suggestions URL in default search provider. |
| 109 bool init_suggestions_url_; | 109 bool init_suggestions_url_; |
| 110 | 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(InstantTestBase); | 111 DISALLOW_COPY_AND_ASSIGN(InstantTestBase); |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ | 114 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ |
| OLD | NEW |