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

Side by Side Diff: content/browser/appcache/appcache_service_unittest.cc

Issue 2800893002: Use ScopedTaskEnvironment instead of MessageLoop in content 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
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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/pickle.h" 13 #include "base/pickle.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/test/scoped_task_environment.h"
16 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
17 #include "content/browser/appcache/appcache_response.h" 18 #include "content/browser/appcache/appcache_response.h"
18 #include "content/browser/appcache/appcache_service_impl.h" 19 #include "content/browser/appcache/appcache_service_impl.h"
19 #include "content/browser/appcache/mock_appcache_storage.h" 20 #include "content/browser/appcache/mock_appcache_storage.h"
20 #include "net/base/completion_callback.h" 21 #include "net/base/completion_callback.h"
21 #include "net/base/io_buffer.h" 22 #include "net/base/io_buffer.h"
22 #include "net/http/http_response_headers.h" 23 #include "net/http/http_response_headers.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 namespace content { 26 namespace content {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 182
182 const GURL kOrigin; 183 const GURL kOrigin;
183 const GURL kManifestUrl; 184 const GURL kManifestUrl;
184 185
185 std::unique_ptr<AppCacheServiceImpl> service_; 186 std::unique_ptr<AppCacheServiceImpl> service_;
186 int delete_result_; 187 int delete_result_;
187 int delete_completion_count_; 188 int delete_completion_count_;
188 net::CompletionCallback deletion_callback_; 189 net::CompletionCallback deletion_callback_;
189 190
190 private: 191 private:
191 base::MessageLoop message_loop_; 192 base::test::ScopedTaskEnvironment scoped_task_environment_;
192 }; 193 };
193 194
194 TEST_F(AppCacheServiceImplTest, DeleteAppCachesForOrigin) { 195 TEST_F(AppCacheServiceImplTest, DeleteAppCachesForOrigin) {
195 // Without giving mock storage simiulated info, should fail. 196 // Without giving mock storage simiulated info, should fail.
196 service_->DeleteAppCachesForOrigin(kOrigin, deletion_callback_); 197 service_->DeleteAppCachesForOrigin(kOrigin, deletion_callback_);
197 EXPECT_EQ(0, delete_completion_count_); 198 EXPECT_EQ(0, delete_completion_count_);
198 base::RunLoop().RunUntilIdle(); 199 base::RunLoop().RunUntilIdle();
199 EXPECT_EQ(1, delete_completion_count_); 200 EXPECT_EQ(1, delete_completion_count_);
200 EXPECT_EQ(net::ERR_FAILED, delete_result_); 201 EXPECT_EQ(net::ERR_FAILED, delete_result_);
201 delete_completion_count_ = 0; 202 delete_completion_count_ = 0;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 EXPECT_EQ(kOneHour, service->reinit_timer_.GetCurrentDelay()); 380 EXPECT_EQ(kOneHour, service->reinit_timer_.GetCurrentDelay());
380 EXPECT_EQ(kOneHour, service->next_reinit_delay_); 381 EXPECT_EQ(kOneHour, service->next_reinit_delay_);
381 382
382 // Fine to delete while pending. 383 // Fine to delete while pending.
383 service.reset(NULL); 384 service.reset(NULL);
384 } 385 }
385 386
386 387
387 388
388 } // namespace content 389 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_quota_client_unittest.cc ('k') | content/browser/appcache/mock_appcache_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698