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/thread_task_runner_handle.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 GCDApiFlowTest() | 46 GCDApiFlowTest() |
47 : ui_thread_(content::BrowserThread::UI, &loop_), | 47 : ui_thread_(content::BrowserThread::UI, &loop_), |
48 request_context_(new net::TestURLRequestContextGetter( | 48 request_context_(new net::TestURLRequestContextGetter( |
49 base::ThreadTaskRunnerHandle::Get())), | 49 base::ThreadTaskRunnerHandle::Get())), |
50 account_id_(kAccountId) {} | 50 account_id_(kAccountId) {} |
51 | 51 |
52 ~GCDApiFlowTest() override {} | 52 ~GCDApiFlowTest() override {} |
53 | 53 |
54 protected: | 54 protected: |
55 void SetUp() override { | 55 void SetUp() override { |
56 token_service_.set_request_context(request_context_.get()); | 56 token_service_.GetFakeOAuth2TokenServiceDelegate()->set_request_context( |
| 57 request_context_.get()); |
57 token_service_.AddAccount(account_id_); | 58 token_service_.AddAccount(account_id_); |
58 ui_thread_.Stop(); // HACK: Fake being on the UI thread | 59 ui_thread_.Stop(); // HACK: Fake being on the UI thread |
59 | 60 |
60 scoped_ptr<MockDelegate> delegate(new MockDelegate); | 61 scoped_ptr<MockDelegate> delegate(new MockDelegate); |
61 mock_delegate_ = delegate.get(); | 62 mock_delegate_ = delegate.get(); |
62 EXPECT_CALL(*mock_delegate_, GetURL()) | 63 EXPECT_CALL(*mock_delegate_, GetURL()) |
63 .WillRepeatedly(Return( | 64 .WillRepeatedly(Return( |
64 GURL("https://www.google.com/cloudprint/confirm?token=SomeToken"))); | 65 GURL("https://www.google.com/cloudprint/confirm?token=SomeToken"))); |
65 gcd_flow_.reset(new GCDApiFlowImpl( | 66 gcd_flow_.reset(new GCDApiFlowImpl( |
66 request_context_.get(), &token_service_, account_id_)); | 67 request_context_.get(), &token_service_, account_id_)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 123 |
123 EXPECT_CALL(*mock_delegate_, | 124 EXPECT_CALL(*mock_delegate_, |
124 OnGCDAPIFlowError(GCDApiFlow::ERROR_MALFORMED_RESPONSE)); | 125 OnGCDAPIFlowError(GCDApiFlow::ERROR_MALFORMED_RESPONSE)); |
125 | 126 |
126 fetcher->delegate()->OnURLFetchComplete(fetcher); | 127 fetcher->delegate()->OnURLFetchComplete(fetcher); |
127 } | 128 } |
128 | 129 |
129 } // namespace | 130 } // namespace |
130 | 131 |
131 } // namespace local_discovery | 132 } // namespace local_discovery |
OLD | NEW |