OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A complete set of unit tests for OAuth2MintTokenFlow. | 5 // A complete set of unit tests for OAuth2MintTokenFlow. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 e1.details.push_back("View and manage your calendars"); | 112 e1.details.push_back("View and manage your calendars"); |
113 ia.push_back(e1); | 113 ia.push_back(e1); |
114 IssueAdviceInfoEntry e2; | 114 IssueAdviceInfoEntry e2; |
115 e2.description = "Manage your documents"; | 115 e2.description = "Manage your documents"; |
116 e2.details.push_back("View your documents"); | 116 e2.details.push_back("View your documents"); |
117 e2.details.push_back("Upload new documents"); | 117 e2.details.push_back("Upload new documents"); |
118 ia.push_back(e2); | 118 ia.push_back(e2); |
119 return ia; | 119 return ia; |
120 } | 120 } |
121 | 121 |
122 } // namespace | |
123 | |
124 class MockDelegate : public OAuth2MintTokenFlow::Delegate { | 122 class MockDelegate : public OAuth2MintTokenFlow::Delegate { |
125 public: | 123 public: |
126 MockDelegate() {} | 124 MockDelegate() {} |
127 ~MockDelegate() {} | 125 ~MockDelegate() {} |
128 | 126 |
129 MOCK_METHOD1(OnMintTokenSuccess, void(const std::string& access_token)); | 127 MOCK_METHOD1(OnMintTokenSuccess, void(const std::string& access_token)); |
130 MOCK_METHOD1(OnIssueAdviceSuccess, | 128 MOCK_METHOD1(OnIssueAdviceSuccess, |
131 void (const IssueAdviceInfo& issue_advice)); | 129 void (const IssueAdviceInfo& issue_advice)); |
132 MOCK_METHOD1(OnMintTokenFailure, | 130 MOCK_METHOD1(OnMintTokenFailure, |
133 void(const GoogleServiceAuthError& error)); | 131 void(const GoogleServiceAuthError& error)); |
134 }; | 132 }; |
135 | 133 |
136 class MockMintTokenFlow : public OAuth2MintTokenFlow { | 134 class MockMintTokenFlow : public OAuth2MintTokenFlow { |
137 public: | 135 public: |
138 explicit MockMintTokenFlow(MockDelegate* delegate, | 136 explicit MockMintTokenFlow(MockDelegate* delegate, |
139 const OAuth2MintTokenFlow::Parameters& parameters ) | 137 const OAuth2MintTokenFlow::Parameters& parameters ) |
140 : OAuth2MintTokenFlow(NULL, delegate, parameters) {} | 138 : OAuth2MintTokenFlow(NULL, delegate, parameters) {} |
141 ~MockMintTokenFlow() {} | 139 ~MockMintTokenFlow() {} |
142 | 140 |
143 MOCK_METHOD0(CreateAccessTokenFetcher, OAuth2AccessTokenFetcher*()); | 141 MOCK_METHOD0(CreateAccessTokenFetcher, OAuth2AccessTokenFetcher*()); |
144 MOCK_METHOD0(CreateMintTokenFetcher, OAuth2MintTokenFetcher*()); | 142 MOCK_METHOD0(CreateMintTokenFetcher, OAuth2MintTokenFetcher*()); |
145 }; | 143 }; |
146 | 144 |
| 145 } // namespace |
| 146 |
147 class OAuth2MintTokenFlowTest : public testing::Test { | 147 class OAuth2MintTokenFlowTest : public testing::Test { |
148 public: | 148 public: |
149 OAuth2MintTokenFlowTest() {} | 149 OAuth2MintTokenFlowTest() {} |
150 virtual ~OAuth2MintTokenFlowTest() { } | 150 virtual ~OAuth2MintTokenFlowTest() { } |
151 | 151 |
152 protected: | 152 protected: |
153 void CreateFlow(OAuth2MintTokenFlow::Mode mode) { | 153 void CreateFlow(OAuth2MintTokenFlow::Mode mode) { |
154 return CreateFlow(&delegate_, mode); | 154 return CreateFlow(&delegate_, mode); |
155 } | 155 } |
156 | 156 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 347 } |
348 | 348 |
349 { // Non-null delegate. | 349 { // Non-null delegate. |
350 GoogleServiceAuthError error( | 350 GoogleServiceAuthError error( |
351 GoogleServiceAuthError::FromConnectionError(101)); | 351 GoogleServiceAuthError::FromConnectionError(101)); |
352 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); | 352 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); |
353 EXPECT_CALL(delegate_, OnMintTokenFailure(error)); | 353 EXPECT_CALL(delegate_, OnMintTokenFailure(error)); |
354 flow_->ProcessMintAccessTokenFailure(error); | 354 flow_->ProcessMintAccessTokenFailure(error); |
355 } | 355 } |
356 } | 356 } |
OLD | NEW |