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 "google_apis/gaia/ubertoken_fetcher.h" | 5 #include "google_apis/gaia/ubertoken_fetcher.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/thread_task_runner_handle.h" |
10 #include "google_apis/gaia/fake_oauth2_token_service.h" | 11 #include "google_apis/gaia/fake_oauth2_token_service.h" |
11 #include "google_apis/gaia/gaia_constants.h" | 12 #include "google_apis/gaia/gaia_constants.h" |
12 #include "net/url_request/test_url_fetcher_factory.h" | 13 #include "net/url_request/test_url_fetcher_factory.h" |
13 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 const char kTestAccountId[] = "test@gmail.com"; | 19 const char kTestAccountId[] = "test@gmail.com"; |
19 | 20 |
(...skipping 21 matching lines...) Expand all Loading... |
41 GoogleServiceAuthError last_error_; | 42 GoogleServiceAuthError last_error_; |
42 int nb_error_; | 43 int nb_error_; |
43 }; | 44 }; |
44 | 45 |
45 } // namespace | 46 } // namespace |
46 | 47 |
47 class UbertokenFetcherTest : public testing::Test { | 48 class UbertokenFetcherTest : public testing::Test { |
48 public: | 49 public: |
49 void SetUp() override { | 50 void SetUp() override { |
50 request_context_getter_ = new net::TestURLRequestContextGetter( | 51 request_context_getter_ = new net::TestURLRequestContextGetter( |
51 base::MessageLoopProxy::current()); | 52 base::ThreadTaskRunnerHandle::Get()); |
52 fetcher_.reset(new UbertokenFetcher(&token_service_, | 53 fetcher_.reset(new UbertokenFetcher(&token_service_, |
53 &consumer_, | 54 &consumer_, |
54 GaiaConstants::kChromeSource, | 55 GaiaConstants::kChromeSource, |
55 request_context_getter_.get())); | 56 request_context_getter_.get())); |
56 } | 57 } |
57 | 58 |
58 void TearDown() override { fetcher_.reset(); } | 59 void TearDown() override { fetcher_.reset(); } |
59 | 60 |
60 protected: | 61 protected: |
61 base::MessageLoop message_loop_; | 62 base::MessageLoop message_loop_; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 EXPECT_EQ(0, consumer_.nb_error_); | 161 EXPECT_EQ(0, consumer_.nb_error_); |
161 EXPECT_EQ(0, consumer_.nb_correct_token_); | 162 EXPECT_EQ(0, consumer_.nb_correct_token_); |
162 EXPECT_EQ("", consumer_.last_token_); | 163 EXPECT_EQ("", consumer_.last_token_); |
163 | 164 |
164 fetcher_->OnGetTokenSuccess(NULL, "accessToken", base::Time()); | 165 fetcher_->OnGetTokenSuccess(NULL, "accessToken", base::Time()); |
165 fetcher_->OnUberAuthTokenSuccess("uberToken"); | 166 fetcher_->OnUberAuthTokenSuccess("uberToken"); |
166 EXPECT_EQ(0, consumer_.nb_error_); | 167 EXPECT_EQ(0, consumer_.nb_error_); |
167 EXPECT_EQ(1, consumer_.nb_correct_token_); | 168 EXPECT_EQ(1, consumer_.nb_correct_token_); |
168 EXPECT_EQ("uberToken", consumer_.last_token_); | 169 EXPECT_EQ("uberToken", consumer_.last_token_); |
169 } | 170 } |
OLD | NEW |