Chromium Code Reviews| 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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_instant_controller.h" | 12 #include "chrome/browser/ui/browser_instant_controller.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/location_bar/location_bar.h" | 14 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 15 #include "chrome/browser/ui/search/instant_controller.h" | 15 #include "chrome/browser/ui/search/instant_controller.h" |
| 16 #include "content/public/test/browser_test_utils.h" | |
| 16 #include "net/test/embedded_test_server/embedded_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 18 | 19 |
| 19 class OmniboxView; | 20 class OmniboxView; |
| 20 | 21 |
| 21 namespace content { | |
| 22 class WebContents; | |
| 23 }; | |
| 24 | |
| 25 // This utility class is meant to be used in a "mix-in" fashion, giving the | 22 // This utility class is meant to be used in a "mix-in" fashion, giving the |
| 26 // derived test class additional Instant-related functionality. | 23 // derived test class additional Instant-related functionality. |
| 27 class InstantTestBase { | 24 class InstantTestBase { |
| 28 protected: | 25 protected: |
| 29 InstantTestBase(); | 26 InstantTestBase(); |
| 30 virtual ~InstantTestBase(); | 27 virtual ~InstantTestBase(); |
| 31 | 28 |
| 32 protected: | 29 protected: |
| 33 void SetupInstant(Browser* browser); | 30 void SetupInstant(Browser* browser); |
| 34 void Init(const GURL& instant_url, const GURL& ntp_url, | 31 void Init(const GURL& instant_url, const GURL& ntp_url, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 48 | 45 |
| 49 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } | 46 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } |
| 50 | 47 |
| 51 void FocusOmnibox(); | 48 void FocusOmnibox(); |
| 52 | 49 |
| 53 void SetOmniboxText(const std::string& text); | 50 void SetOmniboxText(const std::string& text); |
| 54 | 51 |
| 55 void PressEnterAndWaitForNavigation(); | 52 void PressEnterAndWaitForNavigation(); |
| 56 void PressEnterAndWaitForFrameLoad(); | 53 void PressEnterAndWaitForFrameLoad(); |
| 57 | 54 |
| 58 bool GetBoolFromJS(content::WebContents* contents, | 55 bool GetBoolFromJS(const content::ToRenderFrameHost& adapter, |
|
Marc Treib
2017/02/17 17:25:31
This is a Special Hack to that it's possible to pa
sfiera
2017/02/17 17:38:12
Nice implicit conversions.
| |
| 59 const std::string& script, | 56 const std::string& script, |
| 60 bool* result) WARN_UNUSED_RESULT; | 57 bool* result) WARN_UNUSED_RESULT; |
| 61 bool GetIntFromJS(content::WebContents* contents, | 58 bool GetIntFromJS(const content::ToRenderFrameHost& adapter, |
| 62 const std::string& script, | 59 const std::string& script, |
| 63 int* result) WARN_UNUSED_RESULT; | 60 int* result) WARN_UNUSED_RESULT; |
| 64 bool GetDoubleFromJS(content::WebContents* contents, | 61 bool GetDoubleFromJS(const content::ToRenderFrameHost& adapter, |
| 65 const std::string& script, | 62 const std::string& script, |
| 66 double* result) WARN_UNUSED_RESULT; | 63 double* result) WARN_UNUSED_RESULT; |
| 67 bool GetStringFromJS(content::WebContents* contents, | 64 bool GetStringFromJS(const content::ToRenderFrameHost& adapter, |
| 68 const std::string& script, | 65 const std::string& script, |
| 69 std::string* result) WARN_UNUSED_RESULT; | 66 std::string* result) WARN_UNUSED_RESULT; |
| 70 | 67 |
| 71 std::string GetOmniboxText(); | 68 std::string GetOmniboxText(); |
| 72 | 69 |
| 73 // Loads a named image from url |image| from the given |rvh| host. |loaded| | 70 // Loads a named image from url |image| from the given |rvh| host. |loaded| |
| 74 // returns whether the image was able to load without error. | 71 // returns whether the image was able to load without error. |
| 75 // The method returns true if the JavaScript executed cleanly. | 72 // The method returns true if the JavaScript executed cleanly. |
| 76 bool LoadImage(content::RenderViewHost* rvh, | 73 bool LoadImage(content::RenderViewHost* rvh, |
| 77 const std::string& image, | 74 const std::string& image, |
| 78 bool* loaded); | 75 bool* loaded); |
| 79 | 76 |
| 80 private: | 77 private: |
| 81 GURL instant_url_; | 78 GURL instant_url_; |
| 82 GURL ntp_url_; | 79 GURL ntp_url_; |
| 83 | 80 |
| 84 Browser* browser_; | 81 Browser* browser_; |
| 85 | 82 |
| 86 // HTTPS Testing server, started on demand. | 83 // HTTPS Testing server, started on demand. |
| 87 net::EmbeddedTestServer https_test_server_; | 84 net::EmbeddedTestServer https_test_server_; |
| 88 | 85 |
| 89 // Set to true to initialize suggestions URL in default search provider. | 86 // Set to true to initialize suggestions URL in default search provider. |
| 90 bool init_suggestions_url_; | 87 bool init_suggestions_url_; |
| 91 | 88 |
| 92 DISALLOW_COPY_AND_ASSIGN(InstantTestBase); | 89 DISALLOW_COPY_AND_ASSIGN(InstantTestBase); |
| 93 }; | 90 }; |
| 94 | 91 |
| 95 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ | 92 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ |
| OLD | NEW |