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 "chrome/browser/local_discovery/gcd_api_flow.h" | 5 #include "chrome/browser/local_discovery/gcd_api_flow.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "chrome/browser/local_discovery/gcd_api_flow_impl.h" | 11 #include "chrome/browser/local_discovery/gcd_api_flow_impl.h" |
11 #include "content/public/test/test_browser_thread.h" | 12 #include "content/public/test/test_browser_thread.h" |
12 #include "google_apis/gaia/fake_oauth2_token_service.h" | 13 #include "google_apis/gaia/fake_oauth2_token_service.h" |
13 #include "google_apis/gaia/google_service_auth_error.h" | 14 #include "google_apis/gaia/google_service_auth_error.h" |
14 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
16 #include "net/http/http_request_headers.h" | 17 #include "net/http/http_request_headers.h" |
17 #include "net/url_request/test_url_fetcher_factory.h" | 18 #include "net/url_request/test_url_fetcher_factory.h" |
18 #include "net/url_request/url_request_test_util.h" | 19 #include "net/url_request/url_request_test_util.h" |
(...skipping 19 matching lines...) Expand all Loading... |
38 MOCK_METHOD1(OnGCDAPIFlowComplete, void(const base::DictionaryValue&)); | 39 MOCK_METHOD1(OnGCDAPIFlowComplete, void(const base::DictionaryValue&)); |
39 | 40 |
40 MOCK_METHOD0(GetURL, GURL()); | 41 MOCK_METHOD0(GetURL, GURL()); |
41 }; | 42 }; |
42 | 43 |
43 class GCDApiFlowTest : public testing::Test { | 44 class GCDApiFlowTest : public testing::Test { |
44 public: | 45 public: |
45 GCDApiFlowTest() | 46 GCDApiFlowTest() |
46 : ui_thread_(content::BrowserThread::UI, &loop_), | 47 : ui_thread_(content::BrowserThread::UI, &loop_), |
47 request_context_(new net::TestURLRequestContextGetter( | 48 request_context_(new net::TestURLRequestContextGetter( |
48 base::MessageLoopProxy::current())), | 49 base::ThreadTaskRunnerHandle::Get())), |
49 account_id_(kAccountId) {} | 50 account_id_(kAccountId) {} |
50 | 51 |
51 ~GCDApiFlowTest() override {} | 52 ~GCDApiFlowTest() override {} |
52 | 53 |
53 protected: | 54 protected: |
54 void SetUp() override { | 55 void SetUp() override { |
55 token_service_.set_request_context(request_context_.get()); | 56 token_service_.set_request_context(request_context_.get()); |
56 token_service_.AddAccount(account_id_); | 57 token_service_.AddAccount(account_id_); |
57 ui_thread_.Stop(); // HACK: Fake being on the UI thread | 58 ui_thread_.Stop(); // HACK: Fake being on the UI thread |
58 | 59 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 122 |
122 EXPECT_CALL(*mock_delegate_, | 123 EXPECT_CALL(*mock_delegate_, |
123 OnGCDAPIFlowError(GCDApiFlow::ERROR_MALFORMED_RESPONSE)); | 124 OnGCDAPIFlowError(GCDApiFlow::ERROR_MALFORMED_RESPONSE)); |
124 | 125 |
125 fetcher->delegate()->OnURLFetchComplete(fetcher); | 126 fetcher->delegate()->OnURLFetchComplete(fetcher); |
126 } | 127 } |
127 | 128 |
128 } // namespace | 129 } // namespace |
129 | 130 |
130 } // namespace local_discovery | 131 } // namespace local_discovery |
OLD | NEW |