Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/browser/instant/instant_test_utils.h

Issue 11896113: Add chrome-search: access from Instant overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Charlie's comments. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_INSTANT_INSTANT_TEST_UTILS_H_ 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_
6 #define CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_ 6 #define CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
10 #include "base/run_loop.h" 12 #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/instant/instant_model_observer.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_instant_controller.h" 15 #include "chrome/browser/ui/browser_instant_controller.h"
15 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/omnibox/location_bar.h" 17 #include "chrome/browser/ui/omnibox/location_bar.h"
17 #include "chrome/browser/ui/omnibox/omnibox_view.h"
18 #include "chrome/common/search_types.h" 18 #include "chrome/common/search_types.h"
19 #include "chrome/test/base/in_process_browser_test.h" 19 #include "googleurl/src/gurl.h"
20 #include "net/test/test_server.h"
21
22 class InstantController;
23 class InstantModel;
24 class OmniboxView;
25
26 namespace content {
27 class WebContents;
28 };
20 29
21 class InstantTestModelObserver : public InstantModelObserver { 30 class InstantTestModelObserver : public InstantModelObserver {
22 public: 31 public:
23 InstantTestModelObserver(InstantModel* model, 32 InstantTestModelObserver(InstantModel* model,
24 chrome::search::Mode::Type desired_mode_type); 33 chrome::search::Mode::Type desired_mode_type);
25 ~InstantTestModelObserver(); 34 ~InstantTestModelObserver();
26 35
27 void WaitUntilDesiredPreviewState(); 36 void WaitUntilDesiredPreviewState();
28 37
29 // Overridden from InstantModelObserver: 38 // Overridden from InstantModelObserver:
30 virtual void PreviewStateChanged(const InstantModel& model) OVERRIDE; 39 virtual void PreviewStateChanged(const InstantModel& model) OVERRIDE;
31 40
32 private: 41 private:
33 InstantModel* const model_; 42 InstantModel* const model_;
34 const chrome::search::Mode::Type desired_mode_type_; 43 const chrome::search::Mode::Type desired_mode_type_;
35 base::RunLoop run_loop_; 44 base::RunLoop run_loop_;
36 45
37 DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver); 46 DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver);
38 }; 47 };
39 48
40 class InstantTestBase : public InProcessBrowserTest { 49 // This utility class is meant to be used in a "mix-in" fashion, giving the
41 public: 50 // derived test class additional Instant-related functionality.
51 class InstantTestBase {
52 protected:
42 InstantTestBase() 53 InstantTestBase()
43 : https_test_server_( 54 : https_test_server_(
44 net::TestServer::TYPE_HTTPS, 55 net::TestServer::TYPE_HTTPS,
45 net::BaseTestServer::SSLOptions(), 56 net::BaseTestServer::SSLOptions(),
46 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { 57 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {
47 } 58 }
59 virtual ~InstantTestBase() {}
48 60
49 protected: 61 protected:
50 void SetupInstant(); 62 void SetupInstant(Browser* browser);
63 void Init(const GURL& instant_url);
51 64
52 InstantController* instant() { 65 InstantController* instant() {
53 return browser()->instant_controller()->instant(); 66 return browser_->instant_controller()->instant();
54 } 67 }
55 68
56 OmniboxView* omnibox() { 69 OmniboxView* omnibox() {
57 return browser()->window()->GetLocationBar()->GetLocationEntry(); 70 return browser_->window()->GetLocationBar()->GetLocationEntry();
58 } 71 }
59 72
73 const GURL& instant_url() const { return instant_url_; }
74
75 net::TestServer& https_test_server() { return https_test_server_; }
76
60 void KillInstantRenderView(); 77 void KillInstantRenderView();
61 78
62 void FocusOmnibox(); 79 void FocusOmnibox();
63 void FocusOmniboxAndWaitForInstantSupport(); 80 void FocusOmniboxAndWaitForInstantSupport();
81 void FocusOmniboxAndWaitForInstantExtendedSupport();
64 82
65 void SetOmniboxText(const std::string& text); 83 void SetOmniboxText(const std::string& text);
66 void SetOmniboxTextAndWaitForInstantToShow(const std::string& text); 84 void SetOmniboxTextAndWaitForInstantToShow(const std::string& text);
67 85
68 bool GetBoolFromJS(content::WebContents* contents, 86 bool GetBoolFromJS(content::WebContents* contents,
69 const std::string& script, 87 const std::string& script,
70 bool* result) WARN_UNUSED_RESULT; 88 bool* result) WARN_UNUSED_RESULT;
71 bool GetIntFromJS(content::WebContents* contents, 89 bool GetIntFromJS(content::WebContents* contents,
72 const std::string& script, 90 const std::string& script,
73 int* result) WARN_UNUSED_RESULT; 91 int* result) WARN_UNUSED_RESULT;
74 bool GetStringFromJS(content::WebContents* contents, 92 bool GetStringFromJS(content::WebContents* contents,
75 const std::string& script, 93 const std::string& script,
76 std::string* result) WARN_UNUSED_RESULT; 94 std::string* result) WARN_UNUSED_RESULT;
77 bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT; 95 bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT;
78 bool CheckVisibilityIs(content::WebContents* contents, 96 bool CheckVisibilityIs(content::WebContents* contents,
79 bool expected) WARN_UNUSED_RESULT; 97 bool expected) WARN_UNUSED_RESULT;
80 bool HasUserInputInProgress(); 98 bool HasUserInputInProgress();
81 bool HasTemporaryText(); 99 bool HasTemporaryText();
82 100
101 // Loads a named image from url |image| from the given |rvh| host. |loaded|
102 // returns whether the image was able to load without error.
103 // The method returns true if the JavaScript executed cleanly.
104 bool LoadImage(content::RenderViewHost* rvh,
105 const std::string& image,
106 bool* loaded);
107
108 private:
83 GURL instant_url_; 109 GURL instant_url_;
84 110
111 Browser* browser_;
112
85 // HTTPS Testing server, started on demand. 113 // HTTPS Testing server, started on demand.
86 net::TestServer https_test_server_; 114 net::TestServer https_test_server_;
115
116 DISALLOW_COPY_AND_ASSIGN(InstantTestBase);
87 }; 117 };
88 118
89 #endif // CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_ 119 #endif // CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698