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

Side by Side Diff: chrome/browser/search/search_unittest.cc

Issue 150033002: NTP: add histogram to track New Tab page URL status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 10 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/search/search.cc ('k') | tools/metrics/histograms/histograms.xml » ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/metrics/field_trial.h" 6 #include "base/metrics/field_trial.h"
7 #include "base/metrics/histogram_base.h" 7 #include "base/metrics/histogram_base.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 content::NavigationController& controller = contents->GetController(); 514 content::NavigationController& controller = contents->GetController();
515 // Test virtual url chrome://newtab for first NTP of a new profile 515 // Test virtual url chrome://newtab for first NTP of a new profile
516 EXPECT_TRUE(NavEntryIsInstantNTP(contents, 516 EXPECT_TRUE(NavEntryIsInstantNTP(contents,
517 controller.GetLastCommittedEntry())); 517 controller.GetLastCommittedEntry()));
518 // The new_tab_url gets set after the first NTP is visible. 518 // The new_tab_url gets set after the first NTP is visible.
519 SetSearchProvider(true, false); 519 SetSearchProvider(true, false);
520 EXPECT_TRUE(NavEntryIsInstantNTP(contents, 520 EXPECT_TRUE(NavEntryIsInstantNTP(contents,
521 controller.GetLastCommittedEntry())); 521 controller.GetLastCommittedEntry()));
522 } 522 }
523 523
524 TEST_F(SearchTest, UseLocalNTPInIncognito) { 524 TEST_F(SearchTest, NoRewriteInIncognito) {
525 EXPECT_EQ(GURL(), chrome::GetNewTabPageURL( 525 profile()->ForceIncognito(true);
526 profile()->GetOffTheRecordProfile())); 526 EXPECT_EQ(GURL(), chrome::GetNewTabPageURL(profile()));
527 GURL new_tab_url(chrome::kChromeUINewTabURL);
528 EXPECT_FALSE(HandleNewTabURLRewrite(&new_tab_url, profile()));
529 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), new_tab_url);
527 } 530 }
528 531
529 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsInsecure) { 532 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsInsecure) {
530 // Set an insecure new tab page URL and verify that it's ignored. 533 // Set an insecure new tab page URL and verify that it's ignored.
531 SetSearchProvider(true, true); 534 SetSearchProvider(true, true);
532 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), 535 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
533 chrome::GetNewTabPageURL(profile())); 536 chrome::GetNewTabPageURL(profile()));
537 GURL new_tab_url(chrome::kChromeUINewTabURL);
538 EXPECT_TRUE(HandleNewTabURLRewrite(&new_tab_url, profile()));
539 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url);
534 } 540 }
535 541
536 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) { 542 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) {
537 // Set an insecure new tab page URL and verify that it's ignored. 543 // Set an insecure new tab page URL and verify that it's ignored.
538 SetSearchProvider(false, true); 544 SetSearchProvider(false, true);
539 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), 545 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
540 chrome::GetNewTabPageURL(profile())); 546 chrome::GetNewTabPageURL(profile()));
547 GURL new_tab_url(chrome::kChromeUINewTabURL);
548 EXPECT_TRUE(HandleNewTabURLRewrite(&new_tab_url, profile()));
549 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url);
541 } 550 }
542 551
543 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) { 552 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) {
544 // Block access to foo.com in the URL filter. 553 // Block access to foo.com in the URL filter.
545 ManagedUserService* managed_user_service = 554 ManagedUserService* managed_user_service =
546 ManagedUserServiceFactory::GetForProfile(profile()); 555 ManagedUserServiceFactory::GetForProfile(profile());
547 ManagedModeURLFilter* url_filter = 556 ManagedModeURLFilter* url_filter =
548 managed_user_service->GetURLFilterForUIThread(); 557 managed_user_service->GetURLFilterForUIThread();
549 std::map<std::string, bool> hosts; 558 std::map<std::string, bool> hosts;
550 hosts["foo.com"] = false; 559 hosts["foo.com"] = false;
551 url_filter->SetManualHosts(&hosts); 560 url_filter->SetManualHosts(&hosts);
552 561
553 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), 562 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
554 chrome::GetNewTabPageURL(profile())); 563 chrome::GetNewTabPageURL(profile()));
564 GURL new_tab_url(chrome::kChromeUINewTabURL);
565 EXPECT_TRUE(HandleNewTabURLRewrite(&new_tab_url, profile()));
566 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url);
555 EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin, false)); 567 EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin, false));
556 } 568 }
557 569
558 TEST_F(SearchTest, GetInstantURL) { 570 TEST_F(SearchTest, GetInstantURL) {
559 // No Instant URL because "strk" is missing. 571 // No Instant URL because "strk" is missing.
560 SetDefaultInstantTemplateUrl(false); 572 SetDefaultInstantTemplateUrl(false);
561 EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin, false)); 573 EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin, false));
562 574
563 // Set an Instant URL with a valid search terms replacement key. 575 // Set an Instant URL with a valid search terms replacement key.
564 SetDefaultInstantTemplateUrl(true); 576 SetDefaultInstantTemplateUrl(true);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 } 980 }
969 981
970 TEST_F(OriginChipTest, CommandLineOriginChipLeadingMenuButton) { 982 TEST_F(OriginChipTest, CommandLineOriginChipLeadingMenuButton) {
971 CommandLine::ForCurrentProcess()->AppendSwitch( 983 CommandLine::ForCurrentProcess()->AppendSwitch(
972 switches::kEnableOriginChipLeadingMenuButton); 984 switches::kEnableOriginChipLeadingMenuButton);
973 EXPECT_TRUE(ShouldDisplayOriginChip()); 985 EXPECT_TRUE(ShouldDisplayOriginChip());
974 EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition()); 986 EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition());
975 } 987 }
976 988
977 } // namespace chrome 989 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/search/search.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698