OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/safe_browsing/incident_reporting/platform_state_store.h
" | 5 #include "chrome/browser/safe_browsing/incident_reporting/platform_state_store.h
" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/test/test_reg_util_win.h" | 11 #include "base/test/test_reg_util_win.h" |
12 #include "base/test/test_simple_task_runner.h" | 12 #include "base/test/test_simple_task_runner.h" |
13 #include "base/win/registry.h" | 13 #include "base/win/registry.h" |
14 #include "chrome/browser/prefs/browser_prefs.h" | 14 #include "chrome/browser/prefs/browser_prefs.h" |
15 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
17 #include "chrome/test/base/testing_profile_manager.h" | 17 #include "chrome/test/base/testing_profile_manager.h" |
18 #include "components/pref_registry/pref_registry_syncable.h" | 18 #include "components/pref_registry/pref_registry_syncable.h" |
19 #include "components/prefs/pref_notifier_impl.h" | 19 #include "components/prefs/pref_notifier_impl.h" |
20 #include "components/prefs/testing_pref_store.h" | 20 #include "components/prefs/testing_pref_store.h" |
21 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 21 #include "components/sync_preferences/testing_pref_service_syncable.h" |
22 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
25 namespace safe_browsing { | 25 namespace safe_browsing { |
26 namespace platform_state_store { | 26 namespace platform_state_store { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 const char kTestData_[] = "comme un poisson"; | 30 const char kTestData_[] = "comme un poisson"; |
31 const DWORD kTestDataSize_ = sizeof(kTestData_) - 1; | 31 const DWORD kTestDataSize_ = sizeof(kTestData_) - 1; |
(...skipping 23 matching lines...) Expand all Loading... |
55 } | 55 } |
56 // Create a profile with a user PrefStore that can be manipulated. | 56 // Create a profile with a user PrefStore that can be manipulated. |
57 TestingPrefStore* user_pref_store = new TestingPrefStore(); | 57 TestingPrefStore* user_pref_store = new TestingPrefStore(); |
58 // Profile::IsNewProfile() returns true/false on the basis of the pref | 58 // Profile::IsNewProfile() returns true/false on the basis of the pref |
59 // store's read_error property. A profile is considered "New" if it didn't | 59 // store's read_error property. A profile is considered "New" if it didn't |
60 // have a user prefs file. | 60 // have a user prefs file. |
61 user_pref_store->set_read_error( | 61 user_pref_store->set_read_error( |
62 new_profile ? PersistentPrefStore::PREF_READ_ERROR_NO_FILE | 62 new_profile ? PersistentPrefStore::PREF_READ_ERROR_NO_FILE |
63 : PersistentPrefStore::PREF_READ_ERROR_NONE); | 63 : PersistentPrefStore::PREF_READ_ERROR_NONE); |
64 // Ownership of |user_pref_store| is passed to the service. | 64 // Ownership of |user_pref_store| is passed to the service. |
65 std::unique_ptr<syncable_prefs::TestingPrefServiceSyncable> prefs( | 65 std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> prefs( |
66 new syncable_prefs::TestingPrefServiceSyncable( | 66 new sync_preferences::TestingPrefServiceSyncable( |
67 new TestingPrefStore(), user_pref_store, new TestingPrefStore(), | 67 new TestingPrefStore(), user_pref_store, new TestingPrefStore(), |
68 new user_prefs::PrefRegistrySyncable(), new PrefNotifierImpl())); | 68 new user_prefs::PrefRegistrySyncable(), new PrefNotifierImpl())); |
69 chrome::RegisterUserProfilePrefs(prefs->registry()); | 69 chrome::RegisterUserProfilePrefs(prefs->registry()); |
70 profile_ = profile_manager_.CreateTestingProfile( | 70 profile_ = profile_manager_.CreateTestingProfile( |
71 kProfileName_, std::move(prefs), base::UTF8ToUTF16(kProfileName_), 0, | 71 kProfileName_, std::move(prefs), base::UTF8ToUTF16(kProfileName_), 0, |
72 std::string(), TestingProfile::TestingFactories()); | 72 std::string(), TestingProfile::TestingFactories()); |
73 if (new_profile) | 73 if (new_profile) |
74 ASSERT_TRUE(profile_->IsNewProfile()); | 74 ASSERT_TRUE(profile_->IsNewProfile()); |
75 else | 75 else |
76 ASSERT_FALSE(profile_->IsNewProfile()); | 76 ASSERT_FALSE(profile_->IsNewProfile()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 std::string data; | 175 std::string data; |
176 PlatformStateStoreLoadResult result = ReadStoreData(profile_, &data); | 176 PlatformStateStoreLoadResult result = ReadStoreData(profile_, &data); |
177 EXPECT_EQ(PlatformStateStoreLoadResult::CLEARED_DATA, result); | 177 EXPECT_EQ(PlatformStateStoreLoadResult::CLEARED_DATA, result); |
178 EXPECT_EQ(std::string(), data); | 178 EXPECT_EQ(std::string(), data); |
179 AssertTestDataIsAbsent(); | 179 AssertTestDataIsAbsent(); |
180 } | 180 } |
181 | 181 |
182 } // namespace platform_state_store | 182 } // namespace platform_state_store |
183 } // namespace safe_browsing | 183 } // namespace safe_browsing |
OLD | NEW |