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

Side by Side Diff: storage/browser/database/database_quota_client_unittest.cc

Issue 2804703004: Use ScopedTaskEnvironment instead of MessageLoop in storage unit tests. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | storage/browser/fileapi/quota/quota_backend_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/test/scoped_task_environment.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "net/base/completion_callback.h" 17 #include "net/base/completion_callback.h"
17 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
18 #include "storage/browser/database/database_quota_client.h" 19 #include "storage/browser/database/database_quota_client.h"
19 #include "storage/browser/database/database_tracker.h" 20 #include "storage/browser/database/database_tracker.h"
20 #include "storage/browser/database/database_util.h" 21 #include "storage/browser/database/database_util.h"
21 #include "storage/common/database/database_identifier.h" 22 #include "storage/common/database/database_identifier.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 24
24 using storage::DatabaseQuotaClient; 25 using storage::DatabaseQuotaClient;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 void OnGetOriginUsageComplete(int64_t usage) { usage_ = usage; } 186 void OnGetOriginUsageComplete(int64_t usage) { usage_ = usage; }
186 187
187 void OnGetOriginsComplete(const std::set<GURL>& origins) { 188 void OnGetOriginsComplete(const std::set<GURL>& origins) {
188 origins_ = origins; 189 origins_ = origins;
189 } 190 }
190 191
191 void OnDeleteOriginDataComplete(storage::QuotaStatusCode status) { 192 void OnDeleteOriginDataComplete(storage::QuotaStatusCode status) {
192 delete_status_ = status; 193 delete_status_ = status;
193 } 194 }
194 195
195 base::MessageLoop message_loop_; 196 base::test::ScopedTaskEnvironment scoped_task_environment_;
196 int64_t usage_; 197 int64_t usage_;
197 std::set<GURL> origins_; 198 std::set<GURL> origins_;
198 storage::QuotaStatusCode delete_status_; 199 storage::QuotaStatusCode delete_status_;
199 scoped_refptr<MockDatabaseTracker> mock_tracker_; 200 scoped_refptr<MockDatabaseTracker> mock_tracker_;
200 base::WeakPtrFactory<DatabaseQuotaClientTest> weak_factory_; 201 base::WeakPtrFactory<DatabaseQuotaClientTest> weak_factory_;
201 }; 202 };
202 203
203 TEST_F(DatabaseQuotaClientTest, GetOriginUsage) { 204 TEST_F(DatabaseQuotaClientTest, GetOriginUsage) {
204 DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), 205 DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(),
205 mock_tracker()); 206 mock_tracker());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 mock_tracker()->set_async_delete(false); 268 mock_tracker()->set_async_delete(false);
268 EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA)); 269 EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA));
269 EXPECT_EQ(1, mock_tracker()->delete_called_count()); 270 EXPECT_EQ(1, mock_tracker()->delete_called_count());
270 271
271 mock_tracker()->set_async_delete(true); 272 mock_tracker()->set_async_delete(true);
272 EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA)); 273 EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA));
273 EXPECT_EQ(2, mock_tracker()->delete_called_count()); 274 EXPECT_EQ(2, mock_tracker()->delete_called_count());
274 } 275 }
275 276
276 } // namespace content 277 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | storage/browser/fileapi/quota/quota_backend_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698