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 "base/prefs/pref_notifier_impl.h" | 7 #include "base/prefs/pref_notifier_impl.h" |
8 #include "base/prefs/testing_pref_store.h" | 8 #include "base/prefs/testing_pref_store.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/test/test_reg_util_win.h" | 10 #include "base/test/test_reg_util_win.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void AssertTestDataIsPresent() { | 92 void AssertTestDataIsPresent() { |
93 char buffer[kTestDataSize_] = {}; | 93 char buffer[kTestDataSize_] = {}; |
94 base::win::RegKey key; | 94 base::win::RegKey key; |
95 ASSERT_EQ(ERROR_SUCCESS, key.Open(HKEY_CURRENT_USER, kStoreKeyName_, | 95 ASSERT_EQ(ERROR_SUCCESS, key.Open(HKEY_CURRENT_USER, kStoreKeyName_, |
96 KEY_QUERY_VALUE | KEY_WOW64_32KEY)); | 96 KEY_QUERY_VALUE | KEY_WOW64_32KEY)); |
97 DWORD data_size = kTestDataSize_; | 97 DWORD data_size = kTestDataSize_; |
98 DWORD data_type = REG_NONE; | 98 DWORD data_type = REG_NONE; |
99 ASSERT_EQ(ERROR_SUCCESS, | 99 ASSERT_EQ(ERROR_SUCCESS, |
100 key.ReadValue(base::UTF8ToUTF16(kProfileName_).c_str(), | 100 key.ReadValue(base::UTF8ToUTF16(kProfileName_).c_str(), |
101 &buffer[0], &data_size, &data_type)); | 101 &buffer[0], &data_size, &data_type)); |
102 EXPECT_EQ(REG_BINARY, data_type); | 102 EXPECT_EQ(static_cast<DWORD>(REG_BINARY), data_type); |
103 ASSERT_EQ(kTestDataSize_, data_size); | 103 ASSERT_EQ(kTestDataSize_, data_size); |
104 EXPECT_EQ(std::string(&buffer[0], data_size), | 104 EXPECT_EQ(std::string(&buffer[0], data_size), |
105 std::string(&kTestData_[0], kTestDataSize_)); | 105 std::string(&kTestData_[0], kTestDataSize_)); |
106 } | 106 } |
107 | 107 |
108 static const char kProfileName_[]; | 108 static const char kProfileName_[]; |
109 static const base::char16 kStoreKeyName_[]; | 109 static const base::char16 kStoreKeyName_[]; |
110 TestingProfile* profile_; | 110 TestingProfile* profile_; |
111 | 111 |
112 private: | 112 private: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 std::string data; | 172 std::string data; |
173 PlatformStateStoreLoadResult result = ReadStoreData(profile_, &data); | 173 PlatformStateStoreLoadResult result = ReadStoreData(profile_, &data); |
174 EXPECT_EQ(PlatformStateStoreLoadResult::CLEARED_DATA, result); | 174 EXPECT_EQ(PlatformStateStoreLoadResult::CLEARED_DATA, result); |
175 EXPECT_EQ(std::string(), data); | 175 EXPECT_EQ(std::string(), data); |
176 AssertTestDataIsAbsent(); | 176 AssertTestDataIsAbsent(); |
177 } | 177 } |
178 | 178 |
179 } // namespace platform_state_store | 179 } // namespace platform_state_store |
180 } // namespace safe_browsing | 180 } // namespace safe_browsing |
OLD | NEW |