| 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/state_store.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/state_store.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/test_simple_task_runner.h" | 14 #include "base/test/test_simple_task_runner.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/prefs/browser_prefs.h" | 18 #include "chrome/browser/prefs/browser_prefs.h" |
| 19 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" | 19 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" |
| 20 #include "chrome/browser/safe_browsing/incident_reporting/platform_state_store.h
" | 20 #include "chrome/browser/safe_browsing/incident_reporting/platform_state_store.h
" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 24 #include "chrome/test/base/testing_profile_manager.h" | 24 #include "chrome/test/base/testing_profile_manager.h" |
| 25 #include "components/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
| 26 #include "components/syncable_prefs/pref_service_syncable.h" | 26 #include "components/syncable_prefs/pref_service_syncable.h" |
| 27 #include "components/syncable_prefs/pref_service_syncable_factory.h" | 27 #include "components/syncable_prefs/pref_service_syncable_factory.h" |
| 28 #include "extensions/browser/quota_service.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 30 |
| 30 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 31 #include "base/test/test_reg_util_win.h" | 32 #include "base/test/test_reg_util_win.h" |
| 32 #endif | 33 #endif |
| 33 | 34 |
| 34 namespace safe_browsing { | 35 namespace safe_browsing { |
| 35 | 36 |
| 36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 37 | 38 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 static const char kProfileName_[]; | 120 static const char kProfileName_[]; |
| 120 static const TestData kTestData_[]; | 121 static const TestData kTestData_[]; |
| 121 TestingProfile* profile_; | 122 TestingProfile* profile_; |
| 122 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 123 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
| 123 | 124 |
| 124 private: | 125 private: |
| 125 base::FilePath GetPrefsPath() { | 126 base::FilePath GetPrefsPath() { |
| 126 return temp_dir_.path().AppendASCII("prefs"); | 127 return temp_dir_.path().AppendASCII("prefs"); |
| 127 } | 128 } |
| 128 | 129 |
| 130 extensions::QuotaService::ScopedDisablePurgeForTesting |
| 131 disable_purge_for_testing_; |
| 129 base::ScopedTempDir temp_dir_; | 132 base::ScopedTempDir temp_dir_; |
| 130 base::ThreadTaskRunnerHandle thread_task_runner_handle_; | 133 base::ThreadTaskRunnerHandle thread_task_runner_handle_; |
| 131 TestingProfileManager profile_manager_; | 134 TestingProfileManager profile_manager_; |
| 132 | 135 |
| 133 DISALLOW_COPY_AND_ASSIGN(StateStoreTest); | 136 DISALLOW_COPY_AND_ASSIGN(StateStoreTest); |
| 134 }; | 137 }; |
| 135 | 138 |
| 136 // static | 139 // static |
| 137 const char StateStoreTest::kProfileName_[] = "test_profile"; | 140 const char StateStoreTest::kProfileName_[] = "test_profile"; |
| 138 const StateStoreTest::TestData StateStoreTest::kTestData_[] = { | 141 const StateStoreTest::TestData StateStoreTest::kTestData_[] = { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // Verify that the state survived. | 273 // Verify that the state survived. |
| 271 ASSERT_TRUE(state_store.HasBeenReported(data.type, data.key, data.digest)); | 274 ASSERT_TRUE(state_store.HasBeenReported(data.type, data.key, data.digest)); |
| 272 #else | 275 #else |
| 273 // Verify that the state did not survive. | 276 // Verify that the state did not survive. |
| 274 ASSERT_FALSE(state_store.HasBeenReported(data.type, data.key, data.digest)); | 277 ASSERT_FALSE(state_store.HasBeenReported(data.type, data.key, data.digest)); |
| 275 #endif | 278 #endif |
| 276 } | 279 } |
| 277 } | 280 } |
| 278 | 281 |
| 279 } // namespace safe_browsing | 282 } // namespace safe_browsing |
| OLD | NEW |