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

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

Issue 16413002: Moved theme related state from BrowserInstantController to InstantService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/chrome_browser.gypi » ('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 <sstream> 5 #include <sstream>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram_base.h" 9 #include "base/metrics/histogram_base.h"
10 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 EXPECT_TRUE(content::ExecuteScript(ntp, stream.str())); 640 EXPECT_TRUE(content::ExecuteScript(ntp, stream.str()));
641 observer.Wait(); 641 observer.Wait();
642 642
643 // Update Most Visited state. 643 // Update Most Visited state.
644 EXPECT_TRUE(UpdateSearchState(ntp)); 644 EXPECT_TRUE(UpdateSearchState(ntp));
645 645
646 // Make sure we have the same number of items as before. 646 // Make sure we have the same number of items as before.
647 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); 647 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count);
648 } 648 }
649 649
650 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) {
651 InstallThemeSource();
652 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
653 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
654 FocusOmniboxAndWaitForInstantNTPSupport();
655
656 // The "Instant" New Tab should have access to chrome-search: scheme but not
657 // chrome: scheme.
658 ui_test_utils::NavigateToURLWithDisposition(
659 browser(),
660 GURL(chrome::kChromeUINewTabURL),
661 NEW_FOREGROUND_TAB,
662 ui_test_utils::BROWSER_TEST_NONE);
663
664 content::RenderViewHost* rvh =
665 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
666
667 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND");
668 const std::string search_url(
669 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND");
670 bool loaded = false;
671 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded));
672 EXPECT_FALSE(loaded) << chrome_url;
673 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded));
674 EXPECT_TRUE(loaded) << search_url;
675 }
676
677 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. 650 // TODO(dhollowa): Fix flakes. http://crbug.com/179930.
678 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_FaviconAccess) { 651 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_FaviconAccess) {
679 // Create a favicon. 652 // Create a favicon.
680 history::TopSites* top_sites = browser()->profile()->GetTopSites(); 653 history::TopSites* top_sites = browser()->profile()->GetTopSites();
681 GURL url("http://www.google.com/foo.html"); 654 GURL url("http://www.google.com/foo.html");
682 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); 655 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE));
683 ThumbnailScore high_score(0.0, true, true, base::Time::Now()); 656 ThumbnailScore high_score(0.0, true, true, base::Time::Now());
684 EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score)); 657 EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score));
685 658
686 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 659 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 browser()->tab_strip_model()->ActivateTabAt(0, false); 1354 browser()->tab_strip_model()->ActivateTabAt(0, false);
1382 1355
1383 // Switch back to new tab. 1356 // Switch back to new tab.
1384 browser()->tab_strip_model()->ActivateTabAt(1, false); 1357 browser()->tab_strip_model()->ActivateTabAt(1, false);
1385 1358
1386 // Confirm that new tab got no onmostvisitedchanged event. 1359 // Confirm that new tab got no onmostvisitedchanged event.
1387 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 1360 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
1388 EXPECT_TRUE(UpdateSearchState(active_tab)); 1361 EXPECT_TRUE(UpdateSearchState(active_tab));
1389 EXPECT_EQ(2, on_most_visited_change_calls_); 1362 EXPECT_EQ(2, on_most_visited_change_calls_);
1390 } 1363 }
1364
1365 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) {
1366 InstallThemeSource();
1367 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
1368 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1369 FocusOmniboxAndWaitForInstantNTPSupport();
1370
1371 // The "Instant" New Tab should have access to chrome-search: scheme but not
1372 // chrome: scheme.
1373 ui_test_utils::NavigateToURLWithDisposition(
1374 browser(),
1375 GURL(chrome::kChromeUINewTabURL),
1376 NEW_FOREGROUND_TAB,
1377 ui_test_utils::BROWSER_TEST_NONE);
1378
1379 content::RenderViewHost* rvh =
1380 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
1381
1382 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND");
1383 const std::string search_url(
1384 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND");
1385 bool loaded = false;
1386 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded));
1387 EXPECT_FALSE(loaded) << chrome_url;
1388 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded));
1389 EXPECT_TRUE(loaded) << search_url;
1390 }
1391
1392 IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
1393 NoThemeBackgroundChangeEventOnTabSwitch) {
1394 InstallThemeSource();
1395 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1396 FocusOmniboxAndWaitForInstantNTPSupport();
1397
1398 // Install a theme.
1399 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
1400 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1401
1402 // Open new tab. Preloaded NTP contents should have been used.
1403 ui_test_utils::NavigateToURLWithDisposition(
1404 browser(),
1405 GURL(chrome::kChromeUINewTabURL),
1406 NEW_FOREGROUND_TAB,
1407 ui_test_utils::BROWSER_TEST_NONE);
1408 EXPECT_EQ(2, browser()->tab_strip_model()->count());
1409
1410 content::WebContents* active_tab =
1411 browser()->tab_strip_model()->GetActiveWebContents();
1412 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
1413 int on_theme_changed_calls = 0;
1414 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
1415 &on_theme_changed_calls));
1416 EXPECT_EQ(1, on_theme_changed_calls);
1417
1418 // Activate the previous tab.
1419 browser()->tab_strip_model()->ActivateTabAt(0, false);
1420 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
1421
1422 // Switch back to new tab.
1423 browser()->tab_strip_model()->ActivateTabAt(1, false);
1424 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
1425
1426 // Confirm that new tab got no onthemechanged event while switching tabs.
1427 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
1428 on_theme_changed_calls = 0;
1429 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
1430 &on_theme_changed_calls));
1431 EXPECT_EQ(1, on_theme_changed_calls);
1432 }
1433
1434 IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
1435 SendThemeBackgroundChangedEvent) {
1436 InstallThemeSource();
1437 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1438 FocusOmniboxAndWaitForInstantNTPSupport();
1439
1440 // Install a theme.
1441 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
1442
1443 // Open new tab. Preloaded NTP contents should have been used.
1444 ui_test_utils::NavigateToURLWithDisposition(
1445 browser(),
1446 GURL(chrome::kChromeUINewTabURL),
1447 NEW_FOREGROUND_TAB,
1448 ui_test_utils::BROWSER_TEST_NONE);
1449 EXPECT_EQ(2, browser()->tab_strip_model()->count());
1450
1451 // Make sure new tab received an onthemechanged event.
1452 content::WebContents* active_tab =
1453 browser()->tab_strip_model()->GetActiveWebContents();
1454 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
1455 int on_theme_changed_calls = 0;
1456 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
1457 &on_theme_changed_calls));
1458 EXPECT_EQ(1, on_theme_changed_calls);
1459
1460 // Install a new theme.
1461 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme2", "snowflake theme"));
1462
1463 // Confirm that new tab is notified about the theme changed event.
1464 on_theme_changed_calls = 0;
1465 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls",
1466 &on_theme_changed_calls));
1467 EXPECT_EQ(2, on_theme_changed_calls);
1468 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698