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

Side by Side Diff: chrome/browser/prefs/pref_member_unittest.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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/prefs/pref_member.cc ('k') | chrome/browser/prefs/pref_model_associator.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/prefs/pref_member.h" 5 #include "chrome/browser/prefs/pref_member.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/prefs/pref_value_store.h" 8 #include "chrome/browser/prefs/pref_value_store.h"
9 #include "chrome/common/chrome_notification_types.h"
9 #include "chrome/test/testing_pref_service.h" 10 #include "chrome/test/testing_pref_service.h"
10 #include "content/browser/browser_thread.h" 11 #include "content/browser/browser_thread.h"
11 #include "content/common/notification_details.h" 12 #include "content/common/notification_details.h"
12 #include "content/common/notification_source.h" 13 #include "content/common/notification_source.h"
13 #include "content/common/notification_type.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace { 15 namespace {
17 16
18 const char kBoolPref[] = "bool"; 17 const char kBoolPref[] = "bool";
19 const char kIntPref[] = "int"; 18 const char kIntPref[] = "int";
20 const char kDoublePref[] = "double"; 19 const char kDoublePref[] = "double";
21 const char kStringPref[] = "string"; 20 const char kStringPref[] = "string";
22 21
23 void RegisterTestPrefs(PrefService* prefs) { 22 void RegisterTestPrefs(PrefService* prefs) {
24 prefs->RegisterBooleanPref(kBoolPref, false, PrefService::UNSYNCABLE_PREF); 23 prefs->RegisterBooleanPref(kBoolPref, false, PrefService::UNSYNCABLE_PREF);
25 prefs->RegisterIntegerPref(kIntPref, 0, PrefService::UNSYNCABLE_PREF); 24 prefs->RegisterIntegerPref(kIntPref, 0, PrefService::UNSYNCABLE_PREF);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 bool value_; 65 bool value_;
67 }; 66 };
68 67
69 class PrefMemberTestClass : public NotificationObserver { 68 class PrefMemberTestClass : public NotificationObserver {
70 public: 69 public:
71 explicit PrefMemberTestClass(PrefService* prefs) 70 explicit PrefMemberTestClass(PrefService* prefs)
72 : observe_cnt_(0), prefs_(prefs) { 71 : observe_cnt_(0), prefs_(prefs) {
73 str_.Init(kStringPref, prefs, this); 72 str_.Init(kStringPref, prefs, this);
74 } 73 }
75 74
76 virtual void Observe(NotificationType type, 75 virtual void Observe(int type,
77 const NotificationSource& source, 76 const NotificationSource& source,
78 const NotificationDetails& details) { 77 const NotificationDetails& details) {
79 DCHECK(NotificationType::PREF_CHANGED == type); 78 DCHECK(chrome::NOTIFICATION_PREF_CHANGED == type);
80 PrefService* prefs_in = Source<PrefService>(source).ptr(); 79 PrefService* prefs_in = Source<PrefService>(source).ptr();
81 EXPECT_EQ(prefs_in, prefs_); 80 EXPECT_EQ(prefs_in, prefs_);
82 std::string* pref_name_in = Details<std::string>(details).ptr(); 81 std::string* pref_name_in = Details<std::string>(details).ptr();
83 EXPECT_EQ(*pref_name_in, kStringPref); 82 EXPECT_EQ(*pref_name_in, kStringPref);
84 EXPECT_EQ(str_.GetValue(), prefs_->GetString(kStringPref)); 83 EXPECT_EQ(str_.GetValue(), prefs_->GetString(kStringPref));
85 ++observe_cnt_; 84 ++observe_cnt_;
86 } 85 }
87 86
88 StringPrefMember str_; 87 StringPrefMember str_;
89 int observe_cnt_; 88 int observe_cnt_;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 callback->Init(kBoolPref, &prefs); 247 callback->Init(kBoolPref, &prefs);
249 248
250 ASSERT_TRUE(callback->FetchValue()); 249 ASSERT_TRUE(callback->FetchValue());
251 EXPECT_FALSE(callback->value()); 250 EXPECT_FALSE(callback->value());
252 251
253 prefs.SetBoolean(kBoolPref, true); 252 prefs.SetBoolean(kBoolPref, true);
254 253
255 ASSERT_TRUE(callback->FetchValue()); 254 ASSERT_TRUE(callback->FetchValue());
256 EXPECT_TRUE(callback->value()); 255 EXPECT_TRUE(callback->value());
257 } 256 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_member.cc ('k') | chrome/browser/prefs/pref_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698