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

Side by Side Diff: chrome/browser/profiles/off_the_record_profile_impl_unittest.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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) 2012 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/browser/profiles/off_the_record_profile_impl.h" 5 #include "chrome/browser/profiles/off_the_record_profile_impl.h"
6 6
7 #include "chrome/browser/net/ssl_config_service_manager.h" 7 #include "chrome/browser/net/ssl_config_service_manager.h"
8 #include "chrome/browser/prefs/browser_prefs.h" 8 #include "chrome/browser/prefs/browser_prefs.h"
9 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/prefs/scoped_user_pref_update.h" 10 #include "chrome/browser/prefs/scoped_user_pref_update.h"
10 #include "chrome/browser/profiles/profile_dependency_manager.h" 11 #include "chrome/browser/profiles/profile_dependency_manager.h"
11 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
12 #include "chrome/test/base/browser_with_test_window_test.h" 13 #include "chrome/test/base/browser_with_test_window_test.h"
13 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_pref_service.h" 15 #include "chrome/test/base/testing_pref_service.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "content/public/browser/host_zoom_map.h" 17 #include "content/public/browser/host_zoom_map.h"
17 #include "content/public/browser/notification_details.h" 18 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
(...skipping 13 matching lines...) Expand all
32 } 33 }
33 34
34 virtual ~TestingProfileWithHostZoomMap() {} 35 virtual ~TestingProfileWithHostZoomMap() {}
35 36
36 virtual Profile* GetOffTheRecordProfile() OVERRIDE { 37 virtual Profile* GetOffTheRecordProfile() OVERRIDE {
37 if (!off_the_record_profile_.get()) 38 if (!off_the_record_profile_.get())
38 off_the_record_profile_.reset(CreateOffTheRecordProfile()); 39 off_the_record_profile_.reset(CreateOffTheRecordProfile());
39 return off_the_record_profile_.get(); 40 return off_the_record_profile_.get();
40 } 41 }
41 42
42 virtual PrefService* GetOffTheRecordPrefs() OVERRIDE { 43 virtual PrefServiceSyncable* GetOffTheRecordPrefs() OVERRIDE {
43 return GetPrefs(); 44 return GetPrefs();
44 } 45 }
45 46
46 virtual void Observe(int type, 47 virtual void Observe(int type,
47 const content::NotificationSource& source, 48 const content::NotificationSource& source,
48 const content::NotificationDetails& details) OVERRIDE { 49 const content::NotificationDetails& details) OVERRIDE {
49 const std::string& host = 50 const std::string& host =
50 *(content::Details<const std::string>(details).ptr()); 51 *(content::Details<const std::string>(details).ptr());
51 DCHECK(type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED); 52 DCHECK(type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED);
52 if (host.empty()) 53 if (host.empty())
(...skipping 24 matching lines...) Expand all
77 // We need to have a BrowserProcess in g_browser_process variable, since 78 // We need to have a BrowserProcess in g_browser_process variable, since
78 // OffTheRecordProfileImpl ctor uses it in 79 // OffTheRecordProfileImpl ctor uses it in
79 // ProfileIOData::InitializeProfileParams. 80 // ProfileIOData::InitializeProfileParams.
80 class OffTheRecordProfileImplTest : public BrowserWithTestWindowTest { 81 class OffTheRecordProfileImplTest : public BrowserWithTestWindowTest {
81 protected: 82 protected:
82 OffTheRecordProfileImplTest() {} 83 OffTheRecordProfileImplTest() {}
83 84
84 virtual ~OffTheRecordProfileImplTest() {} 85 virtual ~OffTheRecordProfileImplTest() {}
85 86
86 virtual void SetUp() OVERRIDE { 87 virtual void SetUp() OVERRIDE {
87 prefs_.reset(new TestingPrefService); 88 prefs_.reset(new TestingPrefServiceSimple);
88 chrome::RegisterLocalState(prefs_.get()); 89 chrome::RegisterLocalState(prefs_.get());
89 90
90 browser_process()->SetLocalState(prefs_.get()); 91 browser_process()->SetLocalState(prefs_.get());
91 92
92 BrowserWithTestWindowTest::SetUp(); 93 BrowserWithTestWindowTest::SetUp();
93 } 94 }
94 95
95 virtual void TearDown() OVERRIDE { 96 virtual void TearDown() OVERRIDE {
96 BrowserWithTestWindowTest::TearDown(); 97 BrowserWithTestWindowTest::TearDown();
97 browser_process()->SetLocalState(NULL); 98 browser_process()->SetLocalState(NULL);
98 DestroyBrowserAndProfile(); 99 DestroyBrowserAndProfile();
99 prefs_.reset(); 100 prefs_.reset();
100 } 101 }
101 102
102 private: 103 private:
103 TestingBrowserProcess* browser_process() { 104 TestingBrowserProcess* browser_process() {
104 return static_cast<TestingBrowserProcess*>(g_browser_process); 105 return static_cast<TestingBrowserProcess*>(g_browser_process);
105 } 106 }
106 107
107 scoped_ptr<PrefService> prefs_; 108 scoped_ptr<PrefServiceSimple> prefs_;
108 109
109 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImplTest); 110 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImplTest);
110 }; 111 };
111 112
112 // Test four things: 113 // Test four things:
113 // 1. Host zoom maps of parent profile and child profile are different. 114 // 1. Host zoom maps of parent profile and child profile are different.
114 // 2. Child host zoom map inherites zoom level at construction. 115 // 2. Child host zoom map inherites zoom level at construction.
115 // 3. Change of zoom level doesn't propagate from child to parent. 116 // 3. Change of zoom level doesn't propagate from child to parent.
116 // 4. Change of zoom level propagate from parent to child. 117 // 4. Change of zoom level propagate from parent to child.
117 TEST_F(OffTheRecordProfileImplTest, GetHostZoomMap) { 118 TEST_F(OffTheRecordProfileImplTest, GetHostZoomMap) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 child_zoom_map->GetZoomLevel(host)) << 166 child_zoom_map->GetZoomLevel(host)) <<
166 "Child change must not propagate to parent."; 167 "Child change must not propagate to parent.";
167 168
168 parent_zoom_map->SetZoomLevel(host, zoom_level_40); 169 parent_zoom_map->SetZoomLevel(host, zoom_level_40);
169 ASSERT_EQ(parent_zoom_map->GetZoomLevel(host), zoom_level_40); 170 ASSERT_EQ(parent_zoom_map->GetZoomLevel(host), zoom_level_40);
170 171
171 EXPECT_EQ(parent_zoom_map->GetZoomLevel(host), 172 EXPECT_EQ(parent_zoom_map->GetZoomLevel(host),
172 child_zoom_map->GetZoomLevel(host)) << 173 child_zoom_map->GetZoomLevel(host)) <<
173 "Parent change should propagate to child."; 174 "Parent change should propagate to child.";
174 } 175 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/off_the_record_profile_impl.cc ('k') | chrome/browser/profiles/profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698