| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/api/identity/gaia_web_auth_flow.h" | 5 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "content/public/test/test_browser_thread.h" | 11 #include "content/public/test/test_browser_thread.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 | 16 |
| 17 class FakeWebAuthFlow : public WebAuthFlow { | 17 class FakeWebAuthFlow : public WebAuthFlow { |
| 18 public: | 18 public: |
| 19 explicit FakeWebAuthFlow(WebAuthFlow::Delegate* delegate) | 19 explicit FakeWebAuthFlow(WebAuthFlow::Delegate* delegate) |
| 20 : WebAuthFlow(delegate, | 20 : WebAuthFlow(delegate, |
| 21 NULL, | 21 NULL, |
| 22 GURL(), | 22 GURL(), |
| 23 WebAuthFlow::INTERACTIVE) {} | 23 WebAuthFlow::INTERACTIVE) {} |
| 24 | 24 |
| 25 virtual void Start() OVERRIDE {} | 25 virtual void Start() override {} |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 class TestGaiaWebAuthFlow : public GaiaWebAuthFlow { | 28 class TestGaiaWebAuthFlow : public GaiaWebAuthFlow { |
| 29 public: | 29 public: |
| 30 TestGaiaWebAuthFlow(GaiaWebAuthFlow::Delegate* delegate, | 30 TestGaiaWebAuthFlow(GaiaWebAuthFlow::Delegate* delegate, |
| 31 const ExtensionTokenKey* token_key, | 31 const ExtensionTokenKey* token_key, |
| 32 const std::string oauth2_client_id, | 32 const std::string oauth2_client_id, |
| 33 GoogleServiceAuthError::State ubertoken_error_state) | 33 GoogleServiceAuthError::State ubertoken_error_state) |
| 34 : GaiaWebAuthFlow(delegate, NULL, token_key, oauth2_client_id, "en-us"), | 34 : GaiaWebAuthFlow(delegate, NULL, token_key, oauth2_client_id, "en-us"), |
| 35 ubertoken_error_(ubertoken_error_state) {} | 35 ubertoken_error_(ubertoken_error_state) {} |
| 36 | 36 |
| 37 virtual void Start() OVERRIDE { | 37 virtual void Start() override { |
| 38 if (ubertoken_error_.state() == GoogleServiceAuthError::NONE) | 38 if (ubertoken_error_.state() == GoogleServiceAuthError::NONE) |
| 39 OnUbertokenSuccess("fake_ubertoken"); | 39 OnUbertokenSuccess("fake_ubertoken"); |
| 40 else | 40 else |
| 41 OnUbertokenFailure(ubertoken_error_); | 41 OnUbertokenFailure(ubertoken_error_); |
| 42 } | 42 } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 virtual scoped_ptr<WebAuthFlow> CreateWebAuthFlow(GURL url) OVERRIDE { | 45 virtual scoped_ptr<WebAuthFlow> CreateWebAuthFlow(GURL url) override { |
| 46 return scoped_ptr<WebAuthFlow>(new FakeWebAuthFlow(this)); | 46 return scoped_ptr<WebAuthFlow>(new FakeWebAuthFlow(this)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 GoogleServiceAuthError ubertoken_error_; | 49 GoogleServiceAuthError ubertoken_error_; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class MockGaiaWebAuthFlowDelegate : public GaiaWebAuthFlow::Delegate { | 52 class MockGaiaWebAuthFlowDelegate : public GaiaWebAuthFlow::Delegate { |
| 53 public: | 53 public: |
| 54 MOCK_METHOD3(OnGaiaFlowFailure, | 54 MOCK_METHOD3(OnGaiaFlowFailure, |
| 55 void(GaiaWebAuthFlow::Failure failure, | 55 void(GaiaWebAuthFlow::Failure failure, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 EXPECT_CALL( | 231 EXPECT_CALL( |
| 232 delegate_, | 232 delegate_, |
| 233 OnGaiaFlowFailure( | 233 OnGaiaFlowFailure( |
| 234 GaiaWebAuthFlow::WINDOW_CLOSED, | 234 GaiaWebAuthFlow::WINDOW_CLOSED, |
| 235 GoogleServiceAuthError(GoogleServiceAuthError::NONE), | 235 GoogleServiceAuthError(GoogleServiceAuthError::NONE), |
| 236 "")); | 236 "")); |
| 237 flow->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED); | 237 flow->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace extensions | 240 } // namespace extensions |
| OLD | NEW |