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

Side by Side Diff: components/rappor/log_uploader_unittest.cc

Issue 2846723005: Use ScopedTaskEnvironment instead of MessageLoopForUI in components tests. (Closed)
Patch Set: fix-test-errors Created 3 years, 7 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/rappor/log_uploader.h" 5 #include "components/rappor/log_uploader.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/scoped_task_environment.h"
10 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
11 #include "net/url_request/test_url_fetcher_factory.h" 12 #include "net/url_request/test_url_fetcher_factory.h"
12 #include "net/url_request/url_request_test_util.h" 13 #include "net/url_request/url_request_test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace rappor { 16 namespace rappor {
16 17
17 namespace { 18 namespace {
18 19
19 const char kTestServerURL[] = "http://a.com/"; 20 const char kTestServerURL[] = "http://a.com/";
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 54
54 private: 55 private:
55 DISALLOW_COPY_AND_ASSIGN(TestLogUploader); 56 DISALLOW_COPY_AND_ASSIGN(TestLogUploader);
56 }; 57 };
57 58
58 } // namespace 59 } // namespace
59 60
60 class LogUploaderTest : public testing::Test { 61 class LogUploaderTest : public testing::Test {
61 public: 62 public:
62 LogUploaderTest() 63 LogUploaderTest()
63 : request_context_(new net::TestURLRequestContextGetter( 64 : scoped_task_environment_(
65 base::test::ScopedTaskEnvironment::MainThreadType::UI),
66 request_context_(new net::TestURLRequestContextGetter(
64 base::ThreadTaskRunnerHandle::Get())), 67 base::ThreadTaskRunnerHandle::Get())),
65 factory_(NULL) {} 68 factory_(NULL) {}
66 69
67 protected: 70 protected:
68 // Required for base::ThreadTaskRunnerHandle::Get(). 71 // Required for base::ThreadTaskRunnerHandle::Get().
69 base::MessageLoopForUI loop_; 72 base::test::ScopedTaskEnvironment scoped_task_environment_;
70 scoped_refptr<net::TestURLRequestContextGetter> request_context_; 73 scoped_refptr<net::TestURLRequestContextGetter> request_context_;
71 net::FakeURLFetcherFactory factory_; 74 net::FakeURLFetcherFactory factory_;
72 75
73 private: 76 private:
74 DISALLOW_COPY_AND_ASSIGN(LogUploaderTest); 77 DISALLOW_COPY_AND_ASSIGN(LogUploaderTest);
75 }; 78 };
76 79
77 TEST_F(LogUploaderTest, Success) { 80 TEST_F(LogUploaderTest, Success) {
78 TestLogUploader uploader(request_context_.get()); 81 TestLogUploader uploader(request_context_.get());
79 82
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Backoff until the maximum is reached. 153 // Backoff until the maximum is reached.
151 while (next > current) { 154 while (next > current) {
152 current = next; 155 current = next;
153 next = TestLogUploader::BackOff(current); 156 next = TestLogUploader::BackOff(current);
154 } 157 }
155 // Maximum backoff should have been reached. 158 // Maximum backoff should have been reached.
156 EXPECT_EQ(next, current); 159 EXPECT_EQ(next, current);
157 } 160 }
158 161
159 } // namespace rappor 162 } // namespace rappor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698