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

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

Issue 2679583004: Use TaskScheduler instead of WorkerPool in url_request_simple_job.cc. (Closed)
Patch Set: separate thread comment 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
« no previous file with comments | « no previous file | components/update_client/update_checker_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 "components/update_client/request_sender.h" 5 #include "components/update_client/request_sender.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/test/scoped_task_scheduler.h"
14 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
15 #include "components/update_client/test_configurator.h" 16 #include "components/update_client/test_configurator.h"
16 #include "components/update_client/url_request_post_interceptor.h" 17 #include "components/update_client/url_request_post_interceptor.h"
17 #include "net/url_request/url_fetcher.h" 18 #include "net/url_request/url_fetcher.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 namespace update_client { 21 namespace update_client {
21 22
22 namespace { 23 namespace {
23 24
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 std::unique_ptr<InterceptorFactory> interceptor_factory_; 63 std::unique_ptr<InterceptorFactory> interceptor_factory_;
63 64
64 URLRequestPostInterceptor* post_interceptor_1_; // Owned by the factory. 65 URLRequestPostInterceptor* post_interceptor_1_; // Owned by the factory.
65 URLRequestPostInterceptor* post_interceptor_2_; // Owned by the factory. 66 URLRequestPostInterceptor* post_interceptor_2_; // Owned by the factory.
66 67
67 int error_; 68 int error_;
68 std::string response_; 69 std::string response_;
69 70
70 private: 71 private:
71 base::MessageLoopForIO loop_; 72 base::MessageLoopForIO loop_;
73 base::test::ScopedTaskScheduler scoped_task_scheduler_;
72 base::Closure quit_closure_; 74 base::Closure quit_closure_;
73 75
74 DISALLOW_COPY_AND_ASSIGN(RequestSenderTest); 76 DISALLOW_COPY_AND_ASSIGN(RequestSenderTest);
75 }; 77 };
76 78
77 RequestSenderTest::RequestSenderTest() 79 RequestSenderTest::RequestSenderTest()
78 : post_interceptor_1_(nullptr), post_interceptor_2_(nullptr), error_(0) {} 80 : post_interceptor_1_(nullptr),
81 post_interceptor_2_(nullptr),
82 error_(0),
83 scoped_task_scheduler_(&loop_) {}
79 84
80 RequestSenderTest::~RequestSenderTest() {} 85 RequestSenderTest::~RequestSenderTest() {}
81 86
82 void RequestSenderTest::SetUp() { 87 void RequestSenderTest::SetUp() {
83 config_ = new TestConfigurator(base::ThreadTaskRunnerHandle::Get(), 88 config_ = new TestConfigurator(base::ThreadTaskRunnerHandle::Get(),
84 base::ThreadTaskRunnerHandle::Get()); 89 base::ThreadTaskRunnerHandle::Get());
85 interceptor_factory_.reset( 90 interceptor_factory_.reset(
86 new InterceptorFactory(base::ThreadTaskRunnerHandle::Get())); 91 new InterceptorFactory(base::ThreadTaskRunnerHandle::Get()));
87 post_interceptor_1_ = 92 post_interceptor_1_ =
88 interceptor_factory_->CreateInterceptorForPath(kUrlPath1); 93 interceptor_factory_->CreateInterceptorForPath(kUrlPath1);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 << post_interceptor_1_->GetRequestsAsString(); 262 << post_interceptor_1_->GetRequestsAsString();
258 EXPECT_EQ(1, post_interceptor_1_->GetCount()) 263 EXPECT_EQ(1, post_interceptor_1_->GetCount())
259 << post_interceptor_1_->GetRequestsAsString(); 264 << post_interceptor_1_->GetRequestsAsString();
260 265
261 EXPECT_STREQ("test", post_interceptor_1_->GetRequests()[0].c_str()); 266 EXPECT_STREQ("test", post_interceptor_1_->GetRequests()[0].c_str());
262 EXPECT_EQ(RequestSender::kErrorResponseNotTrusted, error_); 267 EXPECT_EQ(RequestSender::kErrorResponseNotTrusted, error_);
263 EXPECT_TRUE(response_.empty()); 268 EXPECT_TRUE(response_.empty());
264 } 269 }
265 270
266 } // namespace update_client 271 } // namespace update_client
OLDNEW
« no previous file with comments | « no previous file | components/update_client/update_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698