OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/sync/sync_stopped_reporter.h" | 5 #include "chrome/browser/sync/sync_stopped_reporter.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/test/test_simple_task_runner.h" | 9 #include "base/test/test_simple_task_runner.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
11 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h" | 11 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h" |
12 #include "chrome/common/chrome_version_info.h" | |
13 #include "net/http/http_status_code.h" | 12 #include "net/http/http_status_code.h" |
14 #include "net/url_request/test_url_fetcher_factory.h" | 13 #include "net/url_request/test_url_fetcher_factory.h" |
15 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
16 #include "sync/protocol/sync.pb.h" | 15 #include "sync/protocol/sync.pb.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "url/gurl.h" | 17 #include "url/gurl.h" |
19 | 18 |
20 using browser_sync::SyncStoppedReporter; | 19 using browser_sync::SyncStoppedReporter; |
21 | 20 |
22 const char kTestURL[] = "http://chromium.org/test"; | 21 const char kTestURL[] = "http://chromium.org/test"; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 53 |
55 const SyncStoppedReporter::Result& request_result() const { | 54 const SyncStoppedReporter::Result& request_result() const { |
56 return request_result_; | 55 return request_result_; |
57 } | 56 } |
58 | 57 |
59 net::URLRequestContextGetter* request_context() { | 58 net::URLRequestContextGetter* request_context() { |
60 return request_context_.get(); | 59 return request_context_.get(); |
61 } | 60 } |
62 | 61 |
63 static std::string GetUserAgent() { | 62 static std::string GetUserAgent() { |
64 chrome::VersionInfo version_info; | 63 return browser_sync::LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi(); |
65 return browser_sync::LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi( | |
66 version_info); | |
67 } | 64 } |
68 | 65 |
69 private: | 66 private: |
70 base::MessageLoop message_loop_; | 67 base::MessageLoop message_loop_; |
71 scoped_refptr<net::URLRequestContextGetter> request_context_; | 68 scoped_refptr<net::URLRequestContextGetter> request_context_; |
72 SyncStoppedReporter::Result request_result_; | 69 SyncStoppedReporter::Result request_result_; |
73 | 70 |
74 DISALLOW_COPY_AND_ASSIGN(SyncStoppedReporterTest); | 71 DISALLOW_COPY_AND_ASSIGN(SyncStoppedReporterTest); |
75 }; | 72 }; |
76 | 73 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 new base::TestSimpleTaskRunner()); | 190 new base::TestSimpleTaskRunner()); |
194 ssr.SetTimerTaskRunnerForTest(task_runner); | 191 ssr.SetTimerTaskRunnerForTest(task_runner); |
195 | 192 |
196 // Begin request. | 193 // Begin request. |
197 ssr.ReportSyncStopped(kAuthToken, kCacheGuid, kBirthday); | 194 ssr.ReportSyncStopped(kAuthToken, kCacheGuid, kBirthday); |
198 | 195 |
199 // Trigger the timeout. | 196 // Trigger the timeout. |
200 ASSERT_TRUE(task_runner->HasPendingTask()); | 197 ASSERT_TRUE(task_runner->HasPendingTask()); |
201 task_runner->RunPendingTasks(); | 198 task_runner->RunPendingTasks(); |
202 } | 199 } |
OLD | NEW |