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

Side by Side Diff: chrome/browser/ui/search/instant_test_base.h

Issue 2857023003: Instant/LocalNTP tests cleanup (Closed)
Patch Set: skip incompatible tests if --site-per-process Created 3 years, 7 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
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_UI_SEARCH_INSTANT_TEST_UTILS_H_ 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_BASE_H_
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_BASE_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"
12 #include "chrome/browser/ui/browser_instant_controller.h"
13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/location_bar/location_bar.h"
15 #include "chrome/browser/ui/search/instant_controller.h"
16 #include "content/public/test/browser_test_utils.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h" 11 #include "net/test/embedded_test_server/embedded_test_server.h"
18 #include "url/gurl.h" 12 #include "url/gurl.h"
19 13
20 class OmniboxView; 14 class Browser;
21 15
22 // This utility class is meant to be used in a "mix-in" fashion, giving the 16 // This utility class is meant to be used in a "mix-in" fashion, giving the
23 // derived test class additional Instant-related functionality. 17 // derived test class additional Instant-related functionality.
24 class InstantTestBase { 18 class InstantTestBase {
25 protected: 19 protected:
26 InstantTestBase(); 20 InstantTestBase();
27 virtual ~InstantTestBase(); 21 virtual ~InstantTestBase();
28 22
29 protected: 23 protected:
24 void set_browser(Browser* browser) { browser_ = browser; }
25 Browser* instant_browser() { return browser_; }
26
30 void SetupInstant(Browser* browser); 27 void SetupInstant(Browser* browser);
31 void Init(const GURL& instant_url, const GURL& ntp_url, 28 void Init(const GURL& instant_url,
29 const GURL& ntp_url,
32 bool init_suggestions_url); 30 bool init_suggestions_url);
33 31
34 void set_browser(Browser* browser) {
35 browser_ = browser;
36 }
37
38 OmniboxView* omnibox() {
39 return browser_->window()->GetLocationBar()->GetOmniboxView();
40 }
41
42 const GURL& instant_url() const { return instant_url_; } 32 const GURL& instant_url() const { return instant_url_; }
43 33
44 const GURL& ntp_url() const { return ntp_url_; } 34 const GURL& ntp_url() const { return ntp_url_; }
45 35
46 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } 36 net::EmbeddedTestServer& https_test_server() { return https_test_server_; }
47 37
48 void FocusOmnibox();
49
50 void SetOmniboxText(const std::string& text);
51
52 void PressEnterAndWaitForNavigation();
53 void PressEnterAndWaitForFrameLoad();
54
55 bool GetBoolFromJS(const content::ToRenderFrameHost& adapter,
56 const std::string& script,
57 bool* result) WARN_UNUSED_RESULT;
58 bool GetIntFromJS(const content::ToRenderFrameHost& adapter,
59 const std::string& script,
60 int* result) WARN_UNUSED_RESULT;
61 bool GetDoubleFromJS(const content::ToRenderFrameHost& adapter,
62 const std::string& script,
63 double* result) WARN_UNUSED_RESULT;
64 bool GetStringFromJS(const content::ToRenderFrameHost& adapter,
65 const std::string& script,
66 std::string* result) WARN_UNUSED_RESULT;
67
68 std::string GetOmniboxText();
69
70 // Loads a named image from url |image| from the given |rvh| host. |loaded|
71 // returns whether the image was able to load without error.
72 // The method returns true if the JavaScript executed cleanly.
73 bool LoadImage(content::RenderViewHost* rvh,
74 const std::string& image,
75 bool* loaded);
76
77 private: 38 private:
78 GURL instant_url_; 39 GURL instant_url_;
79 GURL ntp_url_; 40 GURL ntp_url_;
80 41
81 Browser* browser_; 42 Browser* browser_;
82 43
83 // HTTPS Testing server, started on demand. 44 // HTTPS Testing server, started on demand.
84 net::EmbeddedTestServer https_test_server_; 45 net::EmbeddedTestServer https_test_server_;
85 46
86 // Set to true to initialize suggestions URL in default search provider. 47 // Set to true to initialize suggestions URL in default search provider.
87 bool init_suggestions_url_; 48 bool init_suggestions_url_;
88 49
89 DISALLOW_COPY_AND_ASSIGN(InstantTestBase); 50 DISALLOW_COPY_AND_ASSIGN(InstantTestBase);
90 }; 51 };
91 52
92 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_UTILS_H_ 53 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698