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 OAuth2MintTokenFetcher. | 5 // A complete set of unit tests for OAuth2MintTokenFetcher. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 class MockUrlFetcherFactory : public ScopedURLFetcherFactory, | 50 class MockUrlFetcherFactory : public ScopedURLFetcherFactory, |
51 public URLFetcherFactory { | 51 public URLFetcherFactory { |
52 public: | 52 public: |
53 MockUrlFetcherFactory() | 53 MockUrlFetcherFactory() |
54 : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 54 : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
55 } | 55 } |
56 virtual ~MockUrlFetcherFactory() {} | 56 virtual ~MockUrlFetcherFactory() {} |
57 | 57 |
58 MOCK_METHOD4( | 58 MOCK_METHOD4( |
59 CreateURLFetcher, | 59 CreateURLFetcher, |
60 content::URLFetcher* (int id, | 60 URLFetcher* (int id, |
61 const GURL& url, | 61 const GURL& url, |
62 URLFetcher::RequestType request_type, | 62 URLFetcher::RequestType request_type, |
63 URLFetcherDelegate* d)); | 63 URLFetcherDelegate* d)); |
64 }; | 64 }; |
65 | 65 |
66 class MockOAuth2MintTokenConsumer : public OAuth2MintTokenConsumer { | 66 class MockOAuth2MintTokenConsumer : public OAuth2MintTokenConsumer { |
67 public: | 67 public: |
68 MockOAuth2MintTokenConsumer() {} | 68 MockOAuth2MintTokenConsumer() {} |
69 ~MockOAuth2MintTokenConsumer() {} | 69 ~MockOAuth2MintTokenConsumer() {} |
70 | 70 |
71 MOCK_METHOD1(OnMintTokenSuccess, void(const std::string& access_token)); | 71 MOCK_METHOD1(OnMintTokenSuccess, void(const std::string& access_token)); |
72 MOCK_METHOD1(OnMintTokenFailure, | 72 MOCK_METHOD1(OnMintTokenFailure, |
73 void(const GoogleServiceAuthError& error)); | 73 void(const GoogleServiceAuthError& error)); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 { // Valid json: all good. | 168 { // Valid json: all good. |
169 TestURLFetcher url_fetcher(0, GURL("www.google.com"), NULL); | 169 TestURLFetcher url_fetcher(0, GURL("www.google.com"), NULL); |
170 url_fetcher.SetResponseString(kValidTokenResponse); | 170 url_fetcher.SetResponseString(kValidTokenResponse); |
171 | 171 |
172 std::string at; | 172 std::string at; |
173 EXPECT_TRUE(OAuth2MintTokenFetcher::ParseMintTokenResponse( | 173 EXPECT_TRUE(OAuth2MintTokenFetcher::ParseMintTokenResponse( |
174 &url_fetcher, &at)); | 174 &url_fetcher, &at)); |
175 EXPECT_EQ("at1", at); | 175 EXPECT_EQ("at1", at); |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |