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

Side by Side Diff: chrome/browser/chrome_content_browser_client_unittest.cc

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused. Created 7 years, 1 month 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 #include "chrome/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include "base/metrics/field_trial.h"
8 #include "chrome/browser/search_engines/template_url_service.h"
9 #include "chrome/browser/search_engines/template_url_service_factory.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/browser_with_test_window_test.h"
13 #include "chrome/test/base/ui_test_utils.h"
14 #include "components/variations/entropy_provider.h"
15 #include "content/public/browser/navigation_controller.h"
16 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/web_contents.h"
7 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h" 19 #include "url/gurl.h"
9 20
10 namespace chrome { 21 namespace chrome {
11 22
12 typedef testing::Test ChromeContentBrowserClientTest; 23 typedef testing::Test ChromeContentBrowserClientTest;
13 24
14 25
15 TEST_F(ChromeContentBrowserClientTest, ShouldAssignSiteForURL) { 26 TEST_F(ChromeContentBrowserClientTest, ShouldAssignSiteForURL) {
16 ChromeContentBrowserClient client; 27 ChromeContentBrowserClient client;
17 EXPECT_FALSE(client.ShouldAssignSiteForURL(GURL("chrome-native://test"))); 28 EXPECT_FALSE(client.ShouldAssignSiteForURL(GURL("chrome-native://test")));
18 EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("http://www.google.com"))); 29 EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("http://www.google.com")));
19 EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("https://www.google.com"))); 30 EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("https://www.google.com")));
20 } 31 }
21 32
22 } // namespace chrome 33 } // namespace chrome
34
35 #if !defined(OS_IOS) && !defined(OS_ANDROID)
36 namespace content {
37
38 class InstantNTPURLRewriteTest : public BrowserWithTestWindowTest {
39 protected:
40 virtual void SetUp() OVERRIDE {
41 BrowserWithTestWindowTest::SetUp();
42 field_trial_list_.reset(new base::FieldTrialList(
43 new metrics::SHA1EntropyProvider("42")));
44 }
45
46 void InstallTemplateURLWithNewTabPage(GURL new_tab_page_url) {
47 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
48 profile(), &TemplateURLServiceFactory::BuildInstanceFor);
49 TemplateURLService* template_url_service =
50 TemplateURLServiceFactory::GetForProfile(browser()->profile());
51 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service);
52
53 TemplateURLData data;
54 data.SetURL("http://foo.com/url?bar={searchTerms}");
55 data.new_tab_url = new_tab_page_url.spec();
56 TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
57 // Takes ownership.
58 template_url_service->Add(template_url);
59 template_url_service->SetDefaultSearchProvider(template_url);
60 }
61
62 scoped_ptr<base::FieldTrialList> field_trial_list_;
63 };
64
65 TEST_F(InstantNTPURLRewriteTest, UberURLHandler_InstantExtendedNewTabPage) {
66 const GURL url_original("chrome://newtab");
67 const GURL url_rewritten("https://www.example.com/newtab");
68 InstallTemplateURLWithNewTabPage(url_rewritten);
69 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
70 "Group1 use_cacheable_ntp:1"));
71 AddTab(browser(), GURL("chrome://blank"));
72 NavigateAndCommitActiveTab(url_original);
73
74 NavigationEntry* entry = browser()->tab_strip_model()->
75 GetActiveWebContents()->GetController().GetLastCommittedEntry();
76 ASSERT_TRUE(entry != NULL);
77 EXPECT_EQ(url_rewritten, entry->GetURL());
78 EXPECT_EQ(url_original, entry->GetVirtualURL());
79 }
80
81 } // namespace content
82 #endif // !defined(OS_IOS) && !defined(OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698