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

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: Yet another rebase 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" 13 #include "chrome/browser/instant/instant_controller.h"
12 #include "chrome/browser/instant/instant_overlay_model_observer.h" 14 #include "chrome/browser/instant/instant_overlay_model_observer.h"
13 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_instant_controller.h" 16 #include "chrome/browser/ui/browser_instant_controller.h"
15 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/omnibox/location_bar.h" 18 #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/common/search_types.h"
19 #include "chrome/test/base/in_process_browser_test.h" 20 #include "googleurl/src/gurl.h"
21 #include "net/test/test_server.h"
22
23 class InstantController;
24 class InstantModel;
25 class OmniboxView;
26
27 namespace content {
28 class WebContents;
29 };
20 30
21 class InstantTestModelObserver : public InstantOverlayModelObserver { 31 class InstantTestModelObserver : public InstantOverlayModelObserver {
22 public: 32 public:
23 InstantTestModelObserver(InstantOverlayModel* model, 33 InstantTestModelObserver(InstantOverlayModel* model,
24 chrome::search::Mode::Type desired_mode_type); 34 chrome::search::Mode::Type desired_mode_type);
25 ~InstantTestModelObserver(); 35 ~InstantTestModelObserver();
26 36
27 void WaitForDesiredOverlayState(); 37 void WaitForDesiredOverlayState();
28 38
29 // Overridden from InstantOverlayModelObserver: 39 // Overridden from InstantOverlayModelObserver:
30 virtual void OverlayStateChanged(const InstantOverlayModel& model) OVERRIDE; 40 virtual void OverlayStateChanged(const InstantOverlayModel& model) OVERRIDE;
31 41
32 private: 42 private:
33 InstantOverlayModel* const model_; 43 InstantOverlayModel* const model_;
34 const chrome::search::Mode::Type desired_mode_type_; 44 const chrome::search::Mode::Type desired_mode_type_;
35 base::RunLoop run_loop_; 45 base::RunLoop run_loop_;
36 46
37 DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver); 47 DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver);
38 }; 48 };
39 49
40 class InstantTestBase : public InProcessBrowserTest { 50 // This utility class is meant to be used in a "mix-in" fashion, giving the
41 public: 51 // derived test class additional Instant-related functionality.
52 class InstantTestBase {
53 protected:
42 InstantTestBase() 54 InstantTestBase()
43 : https_test_server_( 55 : https_test_server_(
44 net::TestServer::TYPE_HTTPS, 56 net::TestServer::TYPE_HTTPS,
45 net::BaseTestServer::SSLOptions(), 57 net::BaseTestServer::SSLOptions(),
46 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { 58 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {
47 } 59 }
60 virtual ~InstantTestBase() {}
48 61
49 protected: 62 protected:
50 void SetupInstant(); 63 void SetupInstant(Browser* browser);
64 void Init(const GURL& instant_url);
51 65
52 InstantController* instant() { 66 InstantController* instant() {
53 return browser()->instant_controller()->instant(); 67 return browser_->instant_controller()->instant();
54 } 68 }
55 69
56 OmniboxView* omnibox() { 70 OmniboxView* omnibox() {
57 return browser()->window()->GetLocationBar()->GetLocationEntry(); 71 return browser_->window()->GetLocationBar()->GetLocationEntry();
58 } 72 }
59 73
74 const GURL& instant_url() const { return instant_url_; }
75
76 net::TestServer& https_test_server() { return https_test_server_; }
77
60 void KillInstantRenderView(); 78 void KillInstantRenderView();
61 79
62 void FocusOmnibox(); 80 void FocusOmnibox();
63 void FocusOmniboxAndWaitForInstantSupport(); 81 void FocusOmniboxAndWaitForInstantSupport();
82 void FocusOmniboxAndWaitForInstantExtendedSupport();
64 83
65 void SetOmniboxText(const std::string& text); 84 void SetOmniboxText(const std::string& text);
66 void SetOmniboxTextAndWaitForOverlayToShow(const std::string& text); 85 void SetOmniboxTextAndWaitForOverlayToShow(const std::string& text);
67 86
68 bool GetBoolFromJS(content::WebContents* contents, 87 bool GetBoolFromJS(content::WebContents* contents,
69 const std::string& script, 88 const std::string& script,
70 bool* result) WARN_UNUSED_RESULT; 89 bool* result) WARN_UNUSED_RESULT;
71 bool GetIntFromJS(content::WebContents* contents, 90 bool GetIntFromJS(content::WebContents* contents,
72 const std::string& script, 91 const std::string& script,
73 int* result) WARN_UNUSED_RESULT; 92 int* result) WARN_UNUSED_RESULT;
74 bool GetStringFromJS(content::WebContents* contents, 93 bool GetStringFromJS(content::WebContents* contents,
75 const std::string& script, 94 const std::string& script,
76 std::string* result) WARN_UNUSED_RESULT; 95 std::string* result) WARN_UNUSED_RESULT;
77 bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT; 96 bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT;
78 bool CheckVisibilityIs(content::WebContents* contents, 97 bool CheckVisibilityIs(content::WebContents* contents,
79 bool expected) WARN_UNUSED_RESULT; 98 bool expected) WARN_UNUSED_RESULT;
80 bool HasUserInputInProgress(); 99 bool HasUserInputInProgress();
81 bool HasTemporaryText(); 100 bool HasTemporaryText();
82 101
102 // Loads a named image from url |image| from the given |rvh| host. |loaded|
103 // returns whether the image was able to load without error.
104 // The method returns true if the JavaScript executed cleanly.
105 bool LoadImage(content::RenderViewHost* rvh,
106 const std::string& image,
107 bool* loaded);
108
109 private:
83 GURL instant_url_; 110 GURL instant_url_;
84 111
112 Browser* browser_;
113
85 // HTTPS Testing server, started on demand. 114 // HTTPS Testing server, started on demand.
86 net::TestServer https_test_server_; 115 net::TestServer https_test_server_;
116
117 DISALLOW_COPY_AND_ASSIGN(InstantTestBase);
87 }; 118 };
88 119
89 #endif // CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_ 120 #endif // CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_service_factory.cc ('k') | chrome/browser/instant/instant_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698