| 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 "components/pref_registry/pref_registry_syncable.h" | 7 #include "components/pref_registry/pref_registry_syncable.h" |
| 8 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 8 #include "components/sync_preferences/testing_pref_service_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" |
| 11 | 11 |
| 12 // Unit tests for SessionStartupPref. | 12 // Unit tests for SessionStartupPref. |
| 13 class SessionStartupPrefTest : public testing::Test { | 13 class SessionStartupPrefTest : public testing::Test { |
| 14 public: | 14 public: |
| 15 void SetUp() override { | 15 void SetUp() override { |
| 16 pref_service_.reset(new syncable_prefs::TestingPrefServiceSyncable); | 16 pref_service_.reset(new sync_preferences::TestingPrefServiceSyncable); |
| 17 SessionStartupPref::RegisterProfilePrefs(registry()); | 17 SessionStartupPref::RegisterProfilePrefs(registry()); |
| 18 registry()->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, true); | 18 registry()->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, true); |
| 19 } | 19 } |
| 20 | 20 |
| 21 user_prefs::PrefRegistrySyncable* registry() { | 21 user_prefs::PrefRegistrySyncable* registry() { |
| 22 return pref_service_->registry(); | 22 return pref_service_->registry(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 std::unique_ptr<syncable_prefs::TestingPrefServiceSyncable> pref_service_; | 25 std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> pref_service_; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 TEST_F(SessionStartupPrefTest, URLListIsFixedUp) { | 28 TEST_F(SessionStartupPrefTest, URLListIsFixedUp) { |
| 29 base::ListValue* url_pref_list = new base::ListValue; | 29 base::ListValue* url_pref_list = new base::ListValue; |
| 30 url_pref_list->Set(0, new base::StringValue("google.com")); | 30 url_pref_list->Set(0, new base::StringValue("google.com")); |
| 31 url_pref_list->Set(1, new base::StringValue("chromium.org")); | 31 url_pref_list->Set(1, new base::StringValue("chromium.org")); |
| 32 pref_service_->SetUserPref(prefs::kURLsToRestoreOnStartup, url_pref_list); | 32 pref_service_->SetUserPref(prefs::kURLsToRestoreOnStartup, url_pref_list); |
| 33 | 33 |
| 34 SessionStartupPref result = | 34 SessionStartupPref result = |
| 35 SessionStartupPref::GetStartupPref(pref_service_.get()); | 35 SessionStartupPref::GetStartupPref(pref_service_.get()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 55 EXPECT_EQ(3u, result.urls.size()); | 55 EXPECT_EQ(3u, result.urls.size()); |
| 56 | 56 |
| 57 SessionStartupPref override_test = | 57 SessionStartupPref override_test = |
| 58 SessionStartupPref(SessionStartupPref::URLS); | 58 SessionStartupPref(SessionStartupPref::URLS); |
| 59 override_test.urls.push_back(GURL("dev.chromium.org")); | 59 override_test.urls.push_back(GURL("dev.chromium.org")); |
| 60 SessionStartupPref::SetStartupPref(pref_service_.get(), override_test); | 60 SessionStartupPref::SetStartupPref(pref_service_.get(), override_test); |
| 61 | 61 |
| 62 result = SessionStartupPref::GetStartupPref(pref_service_.get()); | 62 result = SessionStartupPref::GetStartupPref(pref_service_.get()); |
| 63 EXPECT_EQ(3u, result.urls.size()); | 63 EXPECT_EQ(3u, result.urls.size()); |
| 64 } | 64 } |
| OLD | NEW |