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 "chrome/browser/prefs/session_startup_pref.h" | 5 #include "chrome/browser/prefs/session_startup_pref.h" |
6 #include "chrome/common/pref_names.h" | 6 #include "chrome/common/pref_names.h" |
7 #include "chrome/test/base/testing_pref_service_syncable.h" | 7 #include "chrome/test/base/testing_pref_service_syncable.h" |
8 #include "components/pref_registry/pref_registry_syncable.h" | 8 #include "components/pref_registry/pref_registry_syncable.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 user_prefs::PrefRegistrySyncable* registry() { | 43 user_prefs::PrefRegistrySyncable* registry() { |
44 return pref_service_->registry(); | 44 return pref_service_->registry(); |
45 } | 45 } |
46 | 46 |
47 scoped_ptr<TestingPrefServiceSyncable> pref_service_; | 47 scoped_ptr<TestingPrefServiceSyncable> pref_service_; |
48 }; | 48 }; |
49 | 49 |
50 TEST_F(SessionStartupPrefTest, URLListIsFixedUp) { | 50 TEST_F(SessionStartupPrefTest, URLListIsFixedUp) { |
51 base::ListValue* url_pref_list = new base::ListValue; | 51 base::ListValue* url_pref_list = new base::ListValue; |
52 url_pref_list->Set(0, base::Value::CreateStringValue("google.com")); | 52 url_pref_list->Set(0, new base::StringValue("google.com")); |
53 url_pref_list->Set(1, base::Value::CreateStringValue("chromium.org")); | 53 url_pref_list->Set(1, new base::StringValue("chromium.org")); |
54 pref_service_->SetUserPref(prefs::kURLsToRestoreOnStartup, url_pref_list); | 54 pref_service_->SetUserPref(prefs::kURLsToRestoreOnStartup, url_pref_list); |
55 | 55 |
56 SessionStartupPref result = | 56 SessionStartupPref result = |
57 SessionStartupPref::GetStartupPref(pref_service_.get()); | 57 SessionStartupPref::GetStartupPref(pref_service_.get()); |
58 EXPECT_EQ(2u, result.urls.size()); | 58 EXPECT_EQ(2u, result.urls.size()); |
59 EXPECT_EQ("http://google.com/", result.urls[0].spec()); | 59 EXPECT_EQ("http://google.com/", result.urls[0].spec()); |
60 EXPECT_EQ("http://chromium.org/", result.urls[1].spec()); | 60 EXPECT_EQ("http://chromium.org/", result.urls[1].spec()); |
61 } | 61 } |
62 | 62 |
63 TEST_F(SessionStartupPrefTest, URLListManagedOverridesUser) { | 63 TEST_F(SessionStartupPrefTest, URLListManagedOverridesUser) { |
64 base::ListValue* url_pref_list1 = new base::ListValue; | 64 base::ListValue* url_pref_list1 = new base::ListValue; |
65 url_pref_list1->Set(0, base::Value::CreateStringValue("chromium.org")); | 65 url_pref_list1->Set(0, new base::StringValue("chromium.org")); |
66 pref_service_->SetUserPref(prefs::kURLsToRestoreOnStartup, url_pref_list1); | 66 pref_service_->SetUserPref(prefs::kURLsToRestoreOnStartup, url_pref_list1); |
67 | 67 |
68 base::ListValue* url_pref_list2 = new base::ListValue; | 68 base::ListValue* url_pref_list2 = new base::ListValue; |
69 url_pref_list2->Set(0, base::Value::CreateStringValue("chromium.org")); | 69 url_pref_list2->Set(0, new base::StringValue("chromium.org")); |
70 url_pref_list2->Set(1, base::Value::CreateStringValue("chromium.org")); | 70 url_pref_list2->Set(1, new base::StringValue("chromium.org")); |
71 url_pref_list2->Set(2, base::Value::CreateStringValue("chromium.org")); | 71 url_pref_list2->Set(2, new base::StringValue("chromium.org")); |
72 pref_service_->SetManagedPref(prefs::kURLsToRestoreOnStartup, | 72 pref_service_->SetManagedPref(prefs::kURLsToRestoreOnStartup, |
73 url_pref_list2); | 73 url_pref_list2); |
74 | 74 |
75 SessionStartupPref result = | 75 SessionStartupPref result = |
76 SessionStartupPref::GetStartupPref(pref_service_.get()); | 76 SessionStartupPref::GetStartupPref(pref_service_.get()); |
77 EXPECT_EQ(3u, result.urls.size()); | 77 EXPECT_EQ(3u, result.urls.size()); |
78 | 78 |
79 SessionStartupPref override_test = | 79 SessionStartupPref override_test = |
80 SessionStartupPref(SessionStartupPref::URLS); | 80 SessionStartupPref(SessionStartupPref::URLS); |
81 override_test.urls.push_back(GURL("dev.chromium.org")); | 81 override_test.urls.push_back(GURL("dev.chromium.org")); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 // Trigger the migration. | 195 // Trigger the migration. |
196 SessionStartupPref pref = SessionStartupPref::GetStartupPref( | 196 SessionStartupPref pref = SessionStartupPref::GetStartupPref( |
197 pref_service_.get()); | 197 pref_service_.get()); |
198 | 198 |
199 // The pref is now explicit. | 199 // The pref is now explicit. |
200 EXPECT_EQ(SessionStartupPref::LAST, pref.type); | 200 EXPECT_EQ(SessionStartupPref::LAST, pref.type); |
201 EXPECT_FALSE(SessionStartupPref::TypeIsDefault(pref_service_.get())); | 201 EXPECT_FALSE(SessionStartupPref::TypeIsDefault(pref_service_.get())); |
202 } | 202 } |
203 #endif | 203 #endif |
OLD | NEW |