Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/state_store_unittest.cc

Issue 2085673002: Remove calls to MessageLoop::current() in extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_mock_time_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"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 class StateStoreTest : public PlatformStateStoreTestBase { 64 class StateStoreTest : public PlatformStateStoreTestBase {
65 protected: 65 protected:
66 struct TestData { 66 struct TestData {
67 IncidentType type; 67 IncidentType type;
68 const char* key; 68 const char* key;
69 uint32_t digest; 69 uint32_t digest;
70 }; 70 };
71 71
72 StateStoreTest() 72 StateStoreTest()
73 : profile_(nullptr), 73 : profile_(nullptr),
74 task_runner_(new base::TestSimpleTaskRunner()), 74 task_runner_(new base::TestMockTimeTaskRunner()),
75 thread_task_runner_handle_(task_runner_), 75 thread_task_runner_handle_(task_runner_),
76 profile_manager_(TestingBrowserProcess::GetGlobal()) {} 76 profile_manager_(TestingBrowserProcess::GetGlobal()) {}
77 77
78 void SetUp() override { 78 void SetUp() override {
79 PlatformStateStoreTestBase::SetUp(); 79 PlatformStateStoreTestBase::SetUp();
80 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 80 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
81 ASSERT_TRUE(profile_manager_.SetUp()); 81 ASSERT_TRUE(profile_manager_.SetUp());
82 CreateProfile(); 82 CreateProfile();
83 } 83 }
84 84
(...skipping 27 matching lines...) Expand all
112 chrome::RegisterUserProfilePrefs(pref_registry); 112 chrome::RegisterUserProfilePrefs(pref_registry);
113 profile_ = profile_manager_.CreateTestingProfile( 113 profile_ = profile_manager_.CreateTestingProfile(
114 kProfileName_, factory.CreateSyncable(pref_registry), 114 kProfileName_, factory.CreateSyncable(pref_registry),
115 base::UTF8ToUTF16(kProfileName_), 0, std::string(), 115 base::UTF8ToUTF16(kProfileName_), 0, std::string(),
116 TestingProfile::TestingFactories()); 116 TestingProfile::TestingFactories());
117 } 117 }
118 118
119 static const char kProfileName_[]; 119 static const char kProfileName_[];
120 static const TestData kTestData_[]; 120 static const TestData kTestData_[];
121 TestingProfile* profile_; 121 TestingProfile* profile_;
122 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 122 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
123 123
124 private: 124 private:
125 base::FilePath GetPrefsPath() { 125 base::FilePath GetPrefsPath() {
126 return temp_dir_.path().AppendASCII("prefs"); 126 return temp_dir_.path().AppendASCII("prefs");
127 } 127 }
128 128
129 base::ScopedTempDir temp_dir_; 129 base::ScopedTempDir temp_dir_;
130 base::ThreadTaskRunnerHandle thread_task_runner_handle_; 130 base::ThreadTaskRunnerHandle thread_task_runner_handle_;
131 TestingProfileManager profile_manager_; 131 TestingProfileManager profile_manager_;
132 132
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // Verify that the state survived. 270 // Verify that the state survived.
271 ASSERT_TRUE(state_store.HasBeenReported(data.type, data.key, data.digest)); 271 ASSERT_TRUE(state_store.HasBeenReported(data.type, data.key, data.digest));
272 #else 272 #else
273 // Verify that the state did not survive. 273 // Verify that the state did not survive.
274 ASSERT_FALSE(state_store.HasBeenReported(data.type, data.key, data.digest)); 274 ASSERT_FALSE(state_store.HasBeenReported(data.type, data.key, data.digest));
275 #endif 275 #endif
276 } 276 }
277 } 277 }
278 278
279 } // namespace safe_browsing 279 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698