Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: chrome/browser/extensions/api/identity/gaia_web_auth_flow_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
10 #include "base/run_loop.h" 9 #include "base/run_loop.h"
11 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
14 13
15 namespace extensions { 14 namespace extensions {
16 15
17 class FakeWebAuthFlow : public WebAuthFlow { 16 class FakeWebAuthFlow : public WebAuthFlow {
18 public: 17 public:
19 explicit FakeWebAuthFlow(WebAuthFlow::Delegate* delegate) 18 explicit FakeWebAuthFlow(WebAuthFlow::Delegate* delegate)
20 : WebAuthFlow(delegate, 19 : WebAuthFlow(delegate,
21 NULL, 20 NULL,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 GoogleServiceAuthError service_error, 55 GoogleServiceAuthError service_error,
57 const std::string& oauth_error)); 56 const std::string& oauth_error));
58 MOCK_METHOD2(OnGaiaFlowCompleted, 57 MOCK_METHOD2(OnGaiaFlowCompleted,
59 void(const std::string& access_token, 58 void(const std::string& access_token,
60 const std::string& expiration)); 59 const std::string& expiration));
61 }; 60 };
62 61
63 class IdentityGaiaWebAuthFlowTest : public testing::Test { 62 class IdentityGaiaWebAuthFlowTest : public testing::Test {
64 public: 63 public:
65 IdentityGaiaWebAuthFlowTest() 64 IdentityGaiaWebAuthFlowTest()
66 : ubertoken_error_state_(GoogleServiceAuthError::NONE), 65 : ubertoken_error_state_(GoogleServiceAuthError::NONE) {}
67 fake_ui_thread_(content::BrowserThread::UI, &message_loop_) {}
68 66
69 virtual void TearDown() { 67 virtual void TearDown() {
70 testing::Test::TearDown(); 68 testing::Test::TearDown();
71 base::RunLoop loop; 69 base::RunLoop loop;
72 loop.RunUntilIdle(); // Run tasks so FakeWebAuthFlows get deleted. 70 loop.RunUntilIdle(); // Run tasks so FakeWebAuthFlows get deleted.
73 } 71 }
74 72
75 std::unique_ptr<TestGaiaWebAuthFlow> CreateTestFlow() { 73 std::unique_ptr<TestGaiaWebAuthFlow> CreateTestFlow() {
76 ExtensionTokenKey token_key( 74 ExtensionTokenKey token_key(
77 "extension_id", "account_id", std::set<std::string>()); 75 "extension_id", "account_id", std::set<std::string>());
(...skipping 10 matching lines...) Expand all
88 } 86 }
89 87
90 void set_ubertoken_error( 88 void set_ubertoken_error(
91 GoogleServiceAuthError::State ubertoken_error_state) { 89 GoogleServiceAuthError::State ubertoken_error_state) {
92 ubertoken_error_state_ = ubertoken_error_state; 90 ubertoken_error_state_ = ubertoken_error_state;
93 } 91 }
94 92
95 protected: 93 protected:
96 testing::StrictMock<MockGaiaWebAuthFlowDelegate> delegate_; 94 testing::StrictMock<MockGaiaWebAuthFlowDelegate> delegate_;
97 GoogleServiceAuthError::State ubertoken_error_state_; 95 GoogleServiceAuthError::State ubertoken_error_state_;
98 base::MessageLoop message_loop_; 96 content::TestBrowserThreadBundle test_browser_thread_bundle_;
99 content::TestBrowserThread fake_ui_thread_;
100 }; 97 };
101 98
102 TEST_F(IdentityGaiaWebAuthFlowTest, OAuthError) { 99 TEST_F(IdentityGaiaWebAuthFlowTest, OAuthError) {
103 std::unique_ptr<TestGaiaWebAuthFlow> flow = CreateTestFlow(); 100 std::unique_ptr<TestGaiaWebAuthFlow> flow = CreateTestFlow();
104 flow->Start(); 101 flow->Start();
105 EXPECT_CALL(delegate_, OnGaiaFlowFailure( 102 EXPECT_CALL(delegate_, OnGaiaFlowFailure(
106 GaiaWebAuthFlow::OAUTH_ERROR, 103 GaiaWebAuthFlow::OAUTH_ERROR,
107 GoogleServiceAuthError(GoogleServiceAuthError::NONE), 104 GoogleServiceAuthError(GoogleServiceAuthError::NONE),
108 "access_denied")); 105 "access_denied"));
109 flow->OnAuthFlowTitleChange(GetFinalTitle("error=access_denied")); 106 flow->OnAuthFlowTitleChange(GetFinalTitle("error=access_denied"));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 EXPECT_CALL( 228 EXPECT_CALL(
232 delegate_, 229 delegate_,
233 OnGaiaFlowFailure( 230 OnGaiaFlowFailure(
234 GaiaWebAuthFlow::WINDOW_CLOSED, 231 GaiaWebAuthFlow::WINDOW_CLOSED,
235 GoogleServiceAuthError(GoogleServiceAuthError::NONE), 232 GoogleServiceAuthError(GoogleServiceAuthError::NONE),
236 "")); 233 ""));
237 flow->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED); 234 flow->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED);
238 } 235 }
239 236
240 } // namespace extensions 237 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698