| 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 "remoting/test/access_token_fetcher.h" | 5 #include "remoting/test/access_token_fetcher.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 const std::string& data, | 72 const std::string& data, |
| 73 net::HttpStatusCode code, | 73 net::HttpStatusCode code, |
| 74 net::URLRequestStatus::Status status); | 74 net::URLRequestStatus::Status status); |
| 75 | 75 |
| 76 // Used for result verification | 76 // Used for result verification |
| 77 std::string access_token_retrieved_; | 77 std::string access_token_retrieved_; |
| 78 std::string refresh_token_retrieved_; | 78 std::string refresh_token_retrieved_; |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 net::FakeURLFetcherFactory url_fetcher_factory_; | 81 net::FakeURLFetcherFactory url_fetcher_factory_; |
| 82 scoped_ptr<base::MessageLoopForIO> message_loop_; | 82 std::unique_ptr<base::MessageLoopForIO> message_loop_; |
| 83 | 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(AccessTokenFetcherTest); | 84 DISALLOW_COPY_AND_ASSIGN(AccessTokenFetcherTest); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 AccessTokenFetcherTest::AccessTokenFetcherTest() | 87 AccessTokenFetcherTest::AccessTokenFetcherTest() |
| 88 : url_fetcher_factory_(nullptr) { | 88 : url_fetcher_factory_(nullptr) { |
| 89 } | 89 } |
| 90 | 90 |
| 91 AccessTokenFetcherTest::~AccessTokenFetcherTest() { | 91 AccessTokenFetcherTest::~AccessTokenFetcherTest() { |
| 92 } | 92 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 TEST_F(AccessTokenFetcherTest, MultipleAccessTokenCalls) { | 168 TEST_F(AccessTokenFetcherTest, MultipleAccessTokenCalls) { |
| 169 SetFakeResponse(GaiaUrls::GetInstance()->oauth2_token_url(), | 169 SetFakeResponse(GaiaUrls::GetInstance()->oauth2_token_url(), |
| 170 kAuthCodeExchangeValidResponse, net::HTTP_OK, | 170 kAuthCodeExchangeValidResponse, net::HTTP_OK, |
| 171 net::URLRequestStatus::SUCCESS); | 171 net::URLRequestStatus::SUCCESS); |
| 172 | 172 |
| 173 SetFakeResponse(GaiaUrls::GetInstance()->oauth2_token_info_url(), | 173 SetFakeResponse(GaiaUrls::GetInstance()->oauth2_token_info_url(), |
| 174 kValidTokenInfoResponse, net::HTTP_OK, | 174 kValidTokenInfoResponse, net::HTTP_OK, |
| 175 net::URLRequestStatus::SUCCESS); | 175 net::URLRequestStatus::SUCCESS); |
| 176 | 176 |
| 177 scoped_ptr<base::RunLoop> run_loop; | 177 std::unique_ptr<base::RunLoop> run_loop; |
| 178 run_loop.reset(new base::RunLoop()); | 178 run_loop.reset(new base::RunLoop()); |
| 179 AccessTokenCallback access_token_callback = | 179 AccessTokenCallback access_token_callback = |
| 180 base::Bind(&AccessTokenFetcherTest::OnAccessTokenRetrieved, | 180 base::Bind(&AccessTokenFetcherTest::OnAccessTokenRetrieved, |
| 181 base::Unretained(this), run_loop->QuitClosure()); | 181 base::Unretained(this), run_loop->QuitClosure()); |
| 182 | 182 |
| 183 AccessTokenFetcher access_token_fetcher; | 183 AccessTokenFetcher access_token_fetcher; |
| 184 access_token_fetcher.GetAccessTokenFromAuthCode(kAuthCodeValue, | 184 access_token_fetcher.GetAccessTokenFromAuthCode(kAuthCodeValue, |
| 185 access_token_callback); | 185 access_token_callback); |
| 186 | 186 |
| 187 run_loop->Run(); | 187 run_loop->Run(); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 | 400 |
| 401 run_loop.Run(); | 401 run_loop.Run(); |
| 402 | 402 |
| 403 // Our callback should have been called with empty strings. | 403 // Our callback should have been called with empty strings. |
| 404 EXPECT_TRUE(access_token_retrieved_.empty()); | 404 EXPECT_TRUE(access_token_retrieved_.empty()); |
| 405 EXPECT_TRUE(refresh_token_retrieved_.empty()); | 405 EXPECT_TRUE(refresh_token_retrieved_.empty()); |
| 406 } | 406 } |
| 407 | 407 |
| 408 } // namespace test | 408 } // namespace test |
| 409 } // namespace remoting | 409 } // namespace remoting |
| OLD | NEW |