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

Side by Side Diff: chrome/browser/ui/prefs/prefs_tab_helper_unittest.cc

Issue 9706012: Add abstractions that let embedders drive tests of WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove CONTENT_EXPORT on statically linked functions. Merge to head for commit. Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/pref_names.h" 5 #include "chrome/common/pref_names.h"
6 #include "chrome/browser/prefs/pref_service.h" 6 #include "chrome/browser/prefs/pref_service.h"
7 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" 7 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
9 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" 9 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
10 #include "content/browser/tab_contents/test_tab_contents.h"
11 #include "content/test/test_browser_thread.h" 10 #include "content/test/test_browser_thread.h"
12 11
13 using content::BrowserThread; 12 using content::BrowserThread;
14 using content::WebContents; 13 using content::WebContents;
15 14
16 class TestPrefsTabHelper : public PrefsTabHelper { 15 class TestPrefsTabHelper : public PrefsTabHelper {
17 public: 16 public:
18 explicit TestPrefsTabHelper(WebContents* web_contents) 17 explicit TestPrefsTabHelper(WebContents* web_contents)
19 : PrefsTabHelper(web_contents), 18 : PrefsTabHelper(web_contents),
20 was_update_web_preferences_called_(false) { 19 was_update_web_preferences_called_(false) {
(...skipping 29 matching lines...) Expand all
50 return contents_wrapper2_.get(); 49 return contents_wrapper2_.get();
51 } 50 }
52 51
53 TestPrefsTabHelper* CreateTestPrefsTabHelper() { 52 TestPrefsTabHelper* CreateTestPrefsTabHelper() {
54 TestPrefsTabHelper* test_prefs_helper = 53 TestPrefsTabHelper* test_prefs_helper =
55 new TestPrefsTabHelper(contents_wrapper()->web_contents()); 54 new TestPrefsTabHelper(contents_wrapper()->web_contents());
56 contents_wrapper()->prefs_tab_helper_.reset(test_prefs_helper); 55 contents_wrapper()->prefs_tab_helper_.reset(test_prefs_helper);
57 return test_prefs_helper; 56 return test_prefs_helper;
58 } 57 }
59 58
60 void SetContents2(TestTabContents* contents) { 59 void SetContents2(WebContents* contents) {
61 contents_wrapper2_.reset( 60 contents_wrapper2_.reset(
62 contents ? new TabContentsWrapper(contents) : NULL); 61 contents ? new TabContentsWrapper(contents) : NULL);
63 } 62 }
64 63
65 void TestBooleanPreference(const char* key) { 64 void TestBooleanPreference(const char* key) {
66 PrefService* prefs1 = 65 PrefService* prefs1 =
67 contents_wrapper()->prefs_tab_helper()->per_tab_prefs(); 66 contents_wrapper()->prefs_tab_helper()->per_tab_prefs();
68 PrefService* prefs2 = 67 PrefService* prefs2 =
69 contents_wrapper2()->prefs_tab_helper()->per_tab_prefs(); 68 contents_wrapper2()->prefs_tab_helper()->per_tab_prefs();
70 const bool initial_value = prefs1->GetBoolean(key); 69 const bool initial_value = prefs1->GetBoolean(key);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 EXPECT_EQ(modified_value, prefs2->GetString(key)); 134 EXPECT_EQ(modified_value, prefs2->GetString(key));
136 135
137 prefs1->SetString(key, modified_value); 136 prefs1->SetString(key, modified_value);
138 EXPECT_EQ(modified_value, prefs1->GetString(key)); 137 EXPECT_EQ(modified_value, prefs1->GetString(key));
139 EXPECT_EQ(modified_value, prefs2->GetString(key)); 138 EXPECT_EQ(modified_value, prefs2->GetString(key));
140 } 139 }
141 140
142 protected: 141 protected:
143 virtual void SetUp() OVERRIDE { 142 virtual void SetUp() OVERRIDE {
144 TabContentsWrapperTestHarness::SetUp(); 143 TabContentsWrapperTestHarness::SetUp();
145 SetContents2(CreateTestTabContents()); 144 SetContents2(CreateTestWebContents());
146 } 145 }
147 146
148 virtual void TearDown() OVERRIDE { 147 virtual void TearDown() OVERRIDE {
149 contents_wrapper2_.reset(); 148 contents_wrapper2_.reset();
150 TabContentsWrapperTestHarness::TearDown(); 149 TabContentsWrapperTestHarness::TearDown();
151 } 150 }
152 151
153 private: 152 private:
154 content::TestBrowserThread ui_thread_; 153 content::TestBrowserThread ui_thread_;
155 scoped_ptr<TabContentsWrapper> contents_wrapper2_; 154 scoped_ptr<TabContentsWrapper> contents_wrapper2_;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 TEST_F(PrefsTabHelperTest, PerTabFantasyFontFamily) { 225 TEST_F(PrefsTabHelperTest, PerTabFantasyFontFamily) {
227 TestStringPreference(prefs::kWebKitFantasyFontFamily); 226 TestStringPreference(prefs::kWebKitFantasyFontFamily);
228 } 227 }
229 228
230 TEST_F(PrefsTabHelperTest, OverridePrefsOnViewCreation) { 229 TEST_F(PrefsTabHelperTest, OverridePrefsOnViewCreation) {
231 TestPrefsTabHelper* test_prefs_helper = CreateTestPrefsTabHelper(); 230 TestPrefsTabHelper* test_prefs_helper = CreateTestPrefsTabHelper();
232 EXPECT_FALSE(test_prefs_helper->was_update_web_preferences_called()); 231 EXPECT_FALSE(test_prefs_helper->was_update_web_preferences_called());
233 test_prefs_helper->NotifyRenderViewCreated(); 232 test_prefs_helper->NotifyRenderViewCreated();
234 EXPECT_TRUE(test_prefs_helper->was_update_web_preferences_called()); 233 EXPECT_TRUE(test_prefs_helper->was_update_web_preferences_called());
235 } 234 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/base_panel_browser_test.cc ('k') | chrome/browser/ui/select_file_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698