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

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

Issue 20388003: Reload Instant NTP and Instant-process tabs on search url change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Format and lint Created 7 years, 4 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 #include "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/metrics/histogram.h"
7 #include "base/metrics/histogram_samples.h"
8 #include "base/metrics/statistics_recorder.h"
9 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 7 #include "chrome/browser/content_settings/host_content_settings_map.h"
11 #include "chrome/browser/search/search.h" 8 #include "chrome/browser/search/search.h"
12 #include "chrome/browser/ui/search/instant_ntp.h" 9 #include "chrome/browser/ui/search/instant_ntp.h"
13 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h" 10 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h"
14 #include "chrome/common/content_settings.h" 11 #include "chrome/common/content_settings.h"
15 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
16 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
17 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
19 15
20 using base::HistogramBase;
21 using base::HistogramSamples;
22 using base::StatisticsRecorder;
23
24 class TestableInstantNTP : public InstantNTP { 16 class TestableInstantNTP : public InstantNTP {
25 public: 17 public:
26 TestableInstantNTP(InstantNTPPrerenderer* ntp_prerenderer, 18 TestableInstantNTP(InstantNTPPrerenderer* ntp_prerenderer,
27 const std::string& instant_url, 19 const std::string& instant_url,
28 Profile* profile) 20 Profile* profile)
29 : InstantNTP(ntp_prerenderer, instant_url, profile) { 21 : InstantNTP(ntp_prerenderer, instant_url, profile) {
30 } 22 }
31 23
32 // Overrides from InstantPage 24 // Overrides from InstantPage
33 virtual bool supports_instant() const OVERRIDE { 25 virtual bool supports_instant() const OVERRIDE {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 bool override_javascript_enabled_; 112 bool override_javascript_enabled_;
121 bool test_javascript_enabled_; 113 bool test_javascript_enabled_;
122 bool test_in_startup_; 114 bool test_in_startup_;
123 InstantNTP* test_ntp_; 115 InstantNTP* test_ntp_;
124 }; 116 };
125 117
126 class InstantNTPPrerendererTest : public testing::Test { 118 class InstantNTPPrerendererTest : public testing::Test {
127 public: 119 public:
128 InstantNTPPrerendererTest() 120 InstantNTPPrerendererTest()
129 : instant_ntp_prerenderer_(new TestableInstantNTPPrerenderer(&profile_)) { 121 : instant_ntp_prerenderer_(new TestableInstantNTPPrerenderer(&profile_)) {
130 base::StatisticsRecorder::Initialize();
131 chrome::EnableInstantExtendedAPIForTesting(); 122 chrome::EnableInstantExtendedAPIForTesting();
132 } 123 }
133 124
134 TestableInstantNTPPrerenderer* instant_ntp_prerenderer() { 125 TestableInstantNTPPrerenderer* instant_ntp_prerenderer() {
135 return instant_ntp_prerenderer_.get(); 126 return instant_ntp_prerenderer_.get();
136 } 127 }
137 128
138 Profile* profile() { 129 Profile* profile() {
139 return instant_ntp_prerenderer()->profile(); 130 return instant_ntp_prerenderer()->profile();
140 } 131 }
141 132
142 private: 133 private:
143 content::TestBrowserThreadBundle thread_bundle_;
144 scoped_ptr<TestableInstantNTPPrerenderer> instant_ntp_prerenderer_; 134 scoped_ptr<TestableInstantNTPPrerenderer> instant_ntp_prerenderer_;
145 mutable TestingProfile profile_; 135 mutable TestingProfile profile_;
146 }; 136 };
147 137
148 TEST_F(InstantNTPPrerendererTest, PrefersRemoteNTPOnStartup) { 138 TEST_F(InstantNTPPrerendererTest, PrefersRemoteNTPOnStartup) {
149 std::string instant_url("http://instant_url"); 139 std::string instant_url("http://instant_url");
150 scoped_ptr<TestableInstantNTP> ntp(new TestableInstantNTP( 140 scoped_ptr<TestableInstantNTP> ntp(new TestableInstantNTP(
151 instant_ntp_prerenderer(), instant_url, profile())); 141 instant_ntp_prerenderer(), instant_url, profile()));
152 ntp->set_is_local(false); 142 ntp->set_is_local(false);
153 instant_ntp_prerenderer()->set_ntp(ntp.get()); 143 instant_ntp_prerenderer()->set_ntp(ntp.get());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 257
268 TEST_F(InstantNTPPrerendererTest, IsJavascriptEnabledChecksPrefs) { 258 TEST_F(InstantNTPPrerendererTest, IsJavascriptEnabledChecksPrefs) {
269 instant_ntp_prerenderer()->set_override_javascript_enabled(false); 259 instant_ntp_prerenderer()->set_override_javascript_enabled(false);
270 instant_ntp_prerenderer()->profile()->GetPrefs()->SetBoolean( 260 instant_ntp_prerenderer()->profile()->GetPrefs()->SetBoolean(
271 prefs::kWebKitJavascriptEnabled, true); 261 prefs::kWebKitJavascriptEnabled, true);
272 EXPECT_TRUE(instant_ntp_prerenderer()->IsJavascriptEnabled()); 262 EXPECT_TRUE(instant_ntp_prerenderer()->IsJavascriptEnabled());
273 instant_ntp_prerenderer()->profile()->GetPrefs()->SetBoolean( 263 instant_ntp_prerenderer()->profile()->GetPrefs()->SetBoolean(
274 prefs::kWebKitJavascriptEnabled, false); 264 prefs::kWebKitJavascriptEnabled, false);
275 EXPECT_FALSE(instant_ntp_prerenderer()->IsJavascriptEnabled()); 265 EXPECT_FALSE(instant_ntp_prerenderer()->IsJavascriptEnabled());
276 } 266 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698