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

Side by Side Diff: components/update_client/update_checker_unittest.cc

Issue 2679583004: Use TaskScheduler instead of WorkerPool in url_request_simple_job.cc. (Closed)
Patch Set: MessageLoopForIO Created 3 years, 10 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 "components/update_client/update_checker.h" 5 #include "components/update_client/update_checker.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/test/scoped_task_scheduler.h"
18 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
19 #include "base/version.h" 20 #include "base/version.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 #include "components/prefs/testing_pref_service.h" 22 #include "components/prefs/testing_pref_service.h"
22 #include "components/update_client/crx_update_item.h" 23 #include "components/update_client/crx_update_item.h"
23 #include "components/update_client/persisted_data.h" 24 #include "components/update_client/persisted_data.h"
24 #include "components/update_client/test_configurator.h" 25 #include "components/update_client/test_configurator.h"
25 #include "components/update_client/url_request_post_interceptor.h" 26 #include "components/update_client/url_request_post_interceptor.h"
26 #include "net/url_request/url_request_test_util.h" 27 #include "net/url_request/url_request_test_util.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 std::unique_ptr<UpdateChecker> update_checker_; 75 std::unique_ptr<UpdateChecker> update_checker_;
75 76
76 std::unique_ptr<InterceptorFactory> interceptor_factory_; 77 std::unique_ptr<InterceptorFactory> interceptor_factory_;
77 URLRequestPostInterceptor* post_interceptor_; // Owned by the factory. 78 URLRequestPostInterceptor* post_interceptor_; // Owned by the factory.
78 79
79 int error_; 80 int error_;
80 UpdateResponse::Results results_; 81 UpdateResponse::Results results_;
81 82
82 private: 83 private:
83 base::MessageLoopForIO loop_; 84 base::MessageLoopForIO loop_;
85 base::test::ScopedTaskScheduler scoped_task_scheduler_;
84 base::Closure quit_closure_; 86 base::Closure quit_closure_;
85 87
86 DISALLOW_COPY_AND_ASSIGN(UpdateCheckerTest); 88 DISALLOW_COPY_AND_ASSIGN(UpdateCheckerTest);
87 }; 89 };
88 90
89 UpdateCheckerTest::UpdateCheckerTest() : post_interceptor_(NULL), error_(0) { 91 UpdateCheckerTest::UpdateCheckerTest()
90 } 92 : post_interceptor_(NULL), error_(0), scoped_task_scheduler_(&loop_) {}
91 93
92 UpdateCheckerTest::~UpdateCheckerTest() { 94 UpdateCheckerTest::~UpdateCheckerTest() {
93 } 95 }
94 96
95 void UpdateCheckerTest::SetUp() { 97 void UpdateCheckerTest::SetUp() {
96 config_ = new TestConfigurator(base::ThreadTaskRunnerHandle::Get(), 98 config_ = new TestConfigurator(base::ThreadTaskRunnerHandle::Get(),
97 base::ThreadTaskRunnerHandle::Get()); 99 base::ThreadTaskRunnerHandle::Get());
98 pref_.reset(new TestingPrefServiceSimple()); 100 pref_.reset(new TestingPrefServiceSimple());
99 PersistedData::RegisterPrefs(pref_->registry()); 101 PersistedData::RegisterPrefs(pref_->registry());
100 metadata_.reset(new PersistedData(pref_.get())); 102 metadata_.reset(new PersistedData(pref_.get()));
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 509 base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
508 base::Unretained(this))); 510 base::Unretained(this)));
509 RunThreads(); 511 RunThreads();
510 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[3].find( 512 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[3].find(
511 std::string("<app appid=\"") + kUpdateItemId + 513 std::string("<app appid=\"") + kUpdateItemId +
512 "\" version=\"0.9\">" 514 "\" version=\"0.9\">"
513 "<updatecheck/>")); 515 "<updatecheck/>"));
514 } 516 }
515 517
516 } // namespace update_client 518 } // namespace update_client
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698