OLD | NEW |
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 "base/values.h" | 5 #include "base/values.h" |
6 #include "chrome/browser/prefs/overlay_user_pref_store.h" | 6 #include "chrome/browser/prefs/overlay_user_pref_store.h" |
7 #include "chrome/browser/prefs/testing_pref_store.h" | 7 #include "chrome/browser/prefs/testing_pref_store.h" |
8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
9 #include "chrome/common/pref_store_observer_mock.h" | 9 #include "chrome/common/pref_store_observer_mock.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using ::testing::Mock; | 13 using ::testing::Mock; |
14 using ::testing::StrEq; | 14 using ::testing::StrEq; |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const char* overlay_key = prefs::kBrowserWindowPlacement; | 18 const char* overlay_key = prefs::kBrowserWindowPlacement; |
19 const char* regular_key = prefs::kShowBookmarkBar; | 19 const char* regular_key = prefs::kShowBookmarkBar; |
20 const char* mapped_overlay_key = prefs::kWebKitJavascriptEnabled; | 20 // With the removal of the kWebKitGlobalXXX prefs, we'll no longer have real |
21 const char* mapped_underlay_key = prefs::kWebKitGlobalJavascriptEnabled; | 21 // prefs using the overlay pref store, so make up keys here. |
| 22 const char* mapped_overlay_key = "test.per_tab.javascript_enabled"; |
| 23 const char* mapped_underlay_key = "test.per_profile.javascript_enabled"; |
22 | 24 |
23 } // namespace | 25 } // namespace |
24 | 26 |
25 class OverlayUserPrefStoreTest : public testing::Test { | 27 class OverlayUserPrefStoreTest : public testing::Test { |
26 protected: | 28 protected: |
27 OverlayUserPrefStoreTest() | 29 OverlayUserPrefStoreTest() |
28 : underlay_(new TestingPrefStore()), | 30 : underlay_(new TestingPrefStore()), |
29 overlay_(new OverlayUserPrefStore(underlay_.get())) { | 31 overlay_(new OverlayUserPrefStore(underlay_.get())) { |
30 overlay_->RegisterOverlayPref(overlay_key); | 32 overlay_->RegisterOverlayPref(overlay_key); |
31 overlay_->RegisterOverlayPref(mapped_overlay_key, mapped_underlay_key); | 33 overlay_->RegisterOverlayPref(mapped_overlay_key, mapped_underlay_key); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 273 |
272 overlay_->RemoveObserver(&obs); | 274 overlay_->RemoveObserver(&obs); |
273 | 275 |
274 // Check successful unsubscription. | 276 // Check successful unsubscription. |
275 EXPECT_CALL(obs, OnPrefValueChanged(StrEq(mapped_overlay_key))).Times(0); | 277 EXPECT_CALL(obs, OnPrefValueChanged(StrEq(mapped_overlay_key))).Times(0); |
276 EXPECT_CALL(obs, OnPrefValueChanged(StrEq(mapped_underlay_key))).Times(0); | 278 EXPECT_CALL(obs, OnPrefValueChanged(StrEq(mapped_underlay_key))).Times(0); |
277 underlay_->SetValue(mapped_underlay_key, Value::CreateIntegerValue(47)); | 279 underlay_->SetValue(mapped_underlay_key, Value::CreateIntegerValue(47)); |
278 overlay_->SetValue(mapped_overlay_key, Value::CreateIntegerValue(48)); | 280 overlay_->SetValue(mapped_overlay_key, Value::CreateIntegerValue(48)); |
279 Mock::VerifyAndClearExpectations(&obs); | 281 Mock::VerifyAndClearExpectations(&obs); |
280 } | 282 } |
OLD | NEW |