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

Side by Side Diff: chrome/browser/ui/search/instant_extended_interactive_uitest.cc

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
« no previous file with comments | « no previous file | chrome/browser/ui/search/instant_extended_manual_interactive_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <stdint.h> 5 #include <stdint.h>
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/history/history_service_factory.h" 25 #include "chrome/browser/history/history_service_factory.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/search/instant_service.h" 27 #include "chrome/browser/search/instant_service.h"
28 #include "chrome/browser/search/instant_service_factory.h" 28 #include "chrome/browser/search/instant_service_factory.h"
29 #include "chrome/browser/search/search.h" 29 #include "chrome/browser/search/search.h"
30 #include "chrome/browser/search_engines/template_url_service_factory.h" 30 #include "chrome/browser/search_engines/template_url_service_factory.h"
31 #include "chrome/browser/themes/theme_service.h" 31 #include "chrome/browser/themes/theme_service.h"
32 #include "chrome/browser/themes/theme_service_factory.h" 32 #include "chrome/browser/themes/theme_service_factory.h"
33 #include "chrome/browser/ui/browser_list.h" 33 #include "chrome/browser/ui/browser_list.h"
34 #include "chrome/browser/ui/browser_tabstrip.h" 34 #include "chrome/browser/ui/browser_tabstrip.h"
35 #include "chrome/browser/ui/browser_window.h"
36 #include "chrome/browser/ui/location_bar/location_bar.h"
35 #include "chrome/browser/ui/search/instant_tab.h" 37 #include "chrome/browser/ui/search/instant_tab.h"
36 #include "chrome/browser/ui/search/instant_test_utils.h" 38 #include "chrome/browser/ui/search/instant_test_utils.h"
39 #include "chrome/browser/ui/search/instant_uitest_base.h"
37 #include "chrome/browser/ui/search/search_tab_helper.h" 40 #include "chrome/browser/ui/search/search_tab_helper.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" 41 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #include "chrome/browser/ui/webui/theme_source.h" 42 #include "chrome/browser/ui/webui/theme_source.h"
40 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
41 #include "chrome/common/search/instant_types.h" 44 #include "chrome/common/search/instant_types.h"
42 #include "chrome/common/url_constants.h" 45 #include "chrome/common/url_constants.h"
43 #include "chrome/test/base/in_process_browser_test.h" 46 #include "chrome/test/base/in_process_browser_test.h"
44 #include "chrome/test/base/interactive_test_utils.h" 47 #include "chrome/test/base/interactive_test_utils.h"
45 #include "chrome/test/base/ui_test_utils.h" 48 #include "chrome/test/base/ui_test_utils.h"
46 #include "components/bookmarks/browser/bookmark_utils.h" 49 #include "components/bookmarks/browser/bookmark_utils.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 126
124 ~FakeNetworkChangeNotifier() override {} 127 ~FakeNetworkChangeNotifier() override {}
125 128
126 private: 129 private:
127 ConnectionType connection_type_; 130 ConnectionType connection_type_;
128 DISALLOW_COPY_AND_ASSIGN(FakeNetworkChangeNotifier); 131 DISALLOW_COPY_AND_ASSIGN(FakeNetworkChangeNotifier);
129 }; 132 };
130 } // namespace 133 } // namespace
131 134
132 class InstantExtendedTest : public InProcessBrowserTest, 135 class InstantExtendedTest : public InProcessBrowserTest,
133 public InstantTestBase { 136 public InstantUITestBase {
Bernhard Bauer 2017/05/03 16:48:10 I can't say I'm super happy about using multiple i
Marc Treib 2017/05/04 08:25:40 Agreed re multiple inheritance, but one step at a
134 public: 137 public:
135 InstantExtendedTest() 138 InstantExtendedTest()
136 : on_most_visited_change_calls_(0), 139 : on_most_visited_change_calls_(0),
137 most_visited_items_count_(0), 140 most_visited_items_count_(0),
138 first_most_visited_item_id_(0), 141 first_most_visited_item_id_(0),
139 submit_count_(0), 142 submit_count_(0),
140 on_focus_changed_calls_(0), 143 on_focus_changed_calls_(0),
141 is_focused_(false) {} 144 is_focused_(false) {}
142 145
143 protected: 146 protected:
(...skipping 11 matching lines...) Expand all
155 base::StatisticsRecorder::FindHistogram(name); 158 base::StatisticsRecorder::FindHistogram(name);
156 if (!histogram) { 159 if (!histogram) {
157 // If no histogram is found, it's possible that no values have been 160 // If no histogram is found, it's possible that no values have been
158 // recorded yet. Assume that the value is zero. 161 // recorded yet. Assume that the value is zero.
159 return 0; 162 return 0;
160 } 163 }
161 return histogram->SnapshotSamples()->TotalCount(); 164 return histogram->SnapshotSamples()->TotalCount();
162 } 165 }
163 166
164 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT { 167 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT {
165 return GetIntFromJS(contents, "onMostVisitedChangedCalls", 168 return instant_test_utils::GetIntFromJS(contents,
166 &on_most_visited_change_calls_) && 169 "onMostVisitedChangedCalls",
167 GetIntFromJS(contents, "mostVisitedItemsCount", 170 &on_most_visited_change_calls_) &&
168 &most_visited_items_count_) && 171 instant_test_utils::GetIntFromJS(contents, "mostVisitedItemsCount",
169 GetIntFromJS(contents, "firstMostVisitedItemId", 172 &most_visited_items_count_) &&
170 &first_most_visited_item_id_) && 173 instant_test_utils::GetIntFromJS(contents, "firstMostVisitedItemId",
171 GetIntFromJS(contents, "submitCount", 174 &first_most_visited_item_id_) &&
172 &submit_count_) && 175 instant_test_utils::GetIntFromJS(contents, "submitCount",
173 GetStringFromJS(contents, "apiHandle.value", 176 &submit_count_) &&
174 &query_value_) && 177 instant_test_utils::GetStringFromJS(contents, "apiHandle.value",
175 GetIntFromJS(contents, "onFocusChangedCalls", 178 &query_value_) &&
176 &on_focus_changed_calls_) && 179 instant_test_utils::GetIntFromJS(contents, "onFocusChangedCalls",
177 GetBoolFromJS(contents, "isFocused", 180 &on_focus_changed_calls_) &&
178 &is_focused_) && 181 instant_test_utils::GetBoolFromJS(contents, "isFocused",
179 GetStringFromJS(contents, "prefetchQuery", &prefetch_query_value_); 182 &is_focused_) &&
183 instant_test_utils::GetStringFromJS(contents, "prefetchQuery",
184 &prefetch_query_value_);
180 } 185 }
181 186
182 const TemplateURL* GetDefaultSearchProviderTemplateURL() { 187 const TemplateURL* GetDefaultSearchProviderTemplateURL() {
183 TemplateURLService* template_url_service = 188 TemplateURLService* template_url_service =
184 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 189 TemplateURLServiceFactory::GetForProfile(browser()->profile());
185 if (template_url_service) 190 if (template_url_service)
186 return template_url_service->GetDefaultSearchProvider(); 191 return template_url_service->GetDefaultSearchProvider();
187 return NULL; 192 return NULL;
188 } 193 }
189 194
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 263
259 // Used to mock default search provider suggest response. 264 // Used to mock default search provider suggest response.
260 std::unique_ptr<net::FakeURLFetcherFactory> fake_factory_; 265 std::unique_ptr<net::FakeURLFetcherFactory> fake_factory_;
261 266
262 DISALLOW_COPY_AND_ASSIGN(InstantExtendedPrefetchTest); 267 DISALLOW_COPY_AND_ASSIGN(InstantExtendedPrefetchTest);
263 }; 268 };
264 269
265 // Test class used to verify chrome-search: scheme and access policy from the 270 // Test class used to verify chrome-search: scheme and access policy from the
266 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it 271 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it
267 // loads a theme that provides a background image. 272 // loads a theme that provides a background image.
268 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { 273 class InstantPolicyTest : public ExtensionBrowserTest,
274 public InstantUITestBase {
269 public: 275 public:
270 InstantPolicyTest() {} 276 InstantPolicyTest() {}
271 277
272 protected: 278 protected:
273 void SetUpInProcessBrowserTestFixture() override { 279 void SetUpInProcessBrowserTestFixture() override {
274 ASSERT_TRUE(https_test_server().Start()); 280 ASSERT_TRUE(https_test_server().Start());
275 GURL instant_url = 281 GURL instant_url =
276 https_test_server().GetURL("/instant_extended.html?strk=1&"); 282 https_test_server().GetURL("/instant_extended.html?strk=1&");
277 GURL ntp_url = 283 GURL ntp_url =
278 https_test_server().GetURL("/instant_extended_ntp.html?strk=1&"); 284 https_test_server().GetURL("/instant_extended_ntp.html?strk=1&");
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 browser(), GURL(chrome::kChromeUINewTabURL), 454 browser(), GURL(chrome::kChromeUINewTabURL),
449 WindowOpenDisposition::NEW_FOREGROUND_TAB, 455 WindowOpenDisposition::NEW_FOREGROUND_TAB,
450 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | 456 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
451 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 457 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
452 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 458 EXPECT_EQ(2, browser()->tab_strip_model()->count());
453 459
454 content::WebContents* active_tab = 460 content::WebContents* active_tab =
455 browser()->tab_strip_model()->GetActiveWebContents(); 461 browser()->tab_strip_model()->GetActiveWebContents();
456 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 462 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
457 int on_theme_changed_calls = 0; 463 int on_theme_changed_calls = 0;
458 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 464 EXPECT_TRUE(instant_test_utils::GetIntFromJS(
459 &on_theme_changed_calls)); 465 active_tab, "onThemeChangedCalls", &on_theme_changed_calls));
460 EXPECT_EQ(1, on_theme_changed_calls); 466 EXPECT_EQ(1, on_theme_changed_calls);
461 467
462 // Activate the previous tab. 468 // Activate the previous tab.
463 browser()->tab_strip_model()->ActivateTabAt(0, false); 469 browser()->tab_strip_model()->ActivateTabAt(0, false);
464 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); 470 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
465 471
466 // Switch back to new tab. 472 // Switch back to new tab.
467 browser()->tab_strip_model()->ActivateTabAt(1, false); 473 browser()->tab_strip_model()->ActivateTabAt(1, false);
468 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 474 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
469 475
470 // Confirm that new tab got no onthemechanged event while switching tabs. 476 // Confirm that new tab got no onthemechanged event while switching tabs.
471 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 477 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
472 on_theme_changed_calls = 0; 478 on_theme_changed_calls = 0;
473 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 479 EXPECT_TRUE(instant_test_utils::GetIntFromJS(
474 &on_theme_changed_calls)); 480 active_tab, "onThemeChangedCalls", &on_theme_changed_calls));
475 EXPECT_EQ(1, on_theme_changed_calls); 481 EXPECT_EQ(1, on_theme_changed_calls);
476 } 482 }
477 483
478 // Flaky on all bots. http://crbug.com/335297, http://crbug.com/265971. 484 // Flaky on all bots. http://crbug.com/335297, http://crbug.com/265971.
479 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, 485 IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
480 DISABLED_SendThemeBackgroundChangedEvent) { 486 DISABLED_SendThemeBackgroundChangedEvent) {
481 InstallThemeSource(); 487 InstallThemeSource();
482 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 488 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
483 489
484 // Install a theme. 490 // Install a theme.
485 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); 491 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
486 492
487 // Open new tab. 493 // Open new tab.
488 ui_test_utils::NavigateToURLWithDisposition( 494 ui_test_utils::NavigateToURLWithDisposition(
489 browser(), GURL(chrome::kChromeUINewTabURL), 495 browser(), GURL(chrome::kChromeUINewTabURL),
490 WindowOpenDisposition::NEW_FOREGROUND_TAB, 496 WindowOpenDisposition::NEW_FOREGROUND_TAB,
491 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | 497 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
492 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 498 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
493 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 499 EXPECT_EQ(2, browser()->tab_strip_model()->count());
494 500
495 // Make sure new tab received an onthemechanged event. 501 // Make sure new tab received an onthemechanged event.
496 content::WebContents* active_tab = 502 content::WebContents* active_tab =
497 browser()->tab_strip_model()->GetActiveWebContents(); 503 browser()->tab_strip_model()->GetActiveWebContents();
498 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 504 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
499 int on_theme_changed_calls = 0; 505 int on_theme_changed_calls = 0;
500 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 506 EXPECT_TRUE(instant_test_utils::GetIntFromJS(
501 &on_theme_changed_calls)); 507 active_tab, "onThemeChangedCalls", &on_theme_changed_calls));
502 EXPECT_EQ(1, on_theme_changed_calls); 508 EXPECT_EQ(1, on_theme_changed_calls);
503 509
504 // Install a new theme. 510 // Install a new theme.
505 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme2", "snowflake theme")); 511 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme2", "snowflake theme"));
506 512
507 // Confirm that new tab is notified about the theme changed event. 513 // Confirm that new tab is notified about the theme changed event.
508 on_theme_changed_calls = 0; 514 on_theme_changed_calls = 0;
509 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", 515 EXPECT_TRUE(instant_test_utils::GetIntFromJS(
510 &on_theme_changed_calls)); 516 active_tab, "onThemeChangedCalls", &on_theme_changed_calls));
511 EXPECT_EQ(2, on_theme_changed_calls); 517 EXPECT_EQ(2, on_theme_changed_calls);
512 } 518 }
513 519
514 // Flaky on all bots since re-enabled in r208032, crbug.com/253092 520 // Flaky on all bots since re-enabled in r208032, crbug.com/253092
515 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) { 521 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) {
516 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 522 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
517 FocusOmnibox(); 523 FocusOmnibox();
518 524
519 // Open a new tab page. 525 // Open a new tab page.
520 ui_test_utils::NavigateToURLWithDisposition( 526 ui_test_utils::NavigateToURLWithDisposition(
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 stream << "link.href = \"" << result_url.spec() << "\";"; 735 stream << "link.href = \"" << result_url.spec() << "\";";
730 stream << "document.body.appendChild(link);"; 736 stream << "document.body.appendChild(link);";
731 stream << "link.click();"; 737 stream << "link.click();";
732 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); 738 EXPECT_TRUE(content::ExecuteScript(contents, stream.str()));
733 739
734 content::WaitForLoadStop(contents); 740 content::WaitForLoadStop(contents);
735 std::string expected_title = 741 std::string expected_title =
736 "Referrer is " + instant_url().GetWithEmptyPath().spec(); 742 "Referrer is " + instant_url().GetWithEmptyPath().spec();
737 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); 743 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle());
738 } 744 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/search/instant_extended_manual_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698