OLD | NEW |
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/message_loop/message_loop_proxy.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "net/url_request/test_url_fetcher_factory.h" | 9 #include "net/url_request/test_url_fetcher_factory.h" |
10 #include "net/url_request/url_request_test_util.h" | 10 #include "net/url_request/url_request_test_util.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace rappor { | 13 namespace rappor { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 const char kTestServerURL[] = "http://a.com/"; | 17 const char kTestServerURL[] = "http://a.com/"; |
18 const char kTestMimeType[] = "text/plain"; | 18 const char kTestMimeType[] = "text/plain"; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 DISALLOW_COPY_AND_ASSIGN(TestLogUploader); | 52 DISALLOW_COPY_AND_ASSIGN(TestLogUploader); |
53 }; | 53 }; |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 class LogUploaderTest : public testing::Test { | 57 class LogUploaderTest : public testing::Test { |
58 public: | 58 public: |
59 LogUploaderTest() | 59 LogUploaderTest() |
60 : request_context_(new net::TestURLRequestContextGetter( | 60 : request_context_(new net::TestURLRequestContextGetter( |
61 base::MessageLoopProxy::current())), | 61 base::ThreadTaskRunnerHandle::Get())), |
62 factory_(NULL) {} | 62 factory_(NULL) {} |
63 | 63 |
64 protected: | 64 protected: |
65 // Required for base::MessageLoopProxy::current(). | 65 // Required for base::ThreadTaskRunnerHandle::Get(). |
66 base::MessageLoopForUI loop_; | 66 base::MessageLoopForUI loop_; |
67 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 67 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
68 net::FakeURLFetcherFactory factory_; | 68 net::FakeURLFetcherFactory factory_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(LogUploaderTest); | 70 DISALLOW_COPY_AND_ASSIGN(LogUploaderTest); |
71 }; | 71 }; |
72 | 72 |
73 TEST_F(LogUploaderTest, Success) { | 73 TEST_F(LogUploaderTest, Success) { |
74 TestLogUploader uploader(request_context_.get()); | 74 TestLogUploader uploader(request_context_.get()); |
75 | 75 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Backoff until the maximum is reached. | 146 // Backoff until the maximum is reached. |
147 while (next > current) { | 147 while (next > current) { |
148 current = next; | 148 current = next; |
149 next = TestLogUploader::BackOff(current); | 149 next = TestLogUploader::BackOff(current); |
150 } | 150 } |
151 // Maximum backoff should have been reached. | 151 // Maximum backoff should have been reached. |
152 EXPECT_EQ(next, current); | 152 EXPECT_EQ(next, current); |
153 } | 153 } |
154 | 154 |
155 } // namespace rappor | 155 } // namespace rappor |
OLD | NEW |