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

Side by Side Diff: components/policy/core/common/cloud/user_info_fetcher_unittest.cc

Issue 108603005: Update uses of Value in chromeos/, cloud_print/, components/, content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
OLDNEW
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 #include "base/values.h" 5 #include "base/values.h"
6 #include "components/policy/core/common/cloud/user_info_fetcher.h" 6 #include "components/policy/core/common/cloud/user_info_fetcher.h"
7 #include "google_apis/gaia/google_service_auth_error.h" 7 #include "google_apis/gaia/google_service_auth_error.h"
8 #include "net/http/http_status_code.h" 8 #include "net/http/http_status_code.h"
9 #include "net/url_request/test_url_fetcher_factory.h" 9 #include "net/url_request/test_url_fetcher_factory.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 11 matching lines...) Expand all
22 " \"verified_email\": true," 22 " \"verified_email\": true,"
23 " \"hd\": \"test.com\"" 23 " \"hd\": \"test.com\""
24 "}"; 24 "}";
25 25
26 class MockUserInfoFetcherDelegate : public UserInfoFetcher::Delegate { 26 class MockUserInfoFetcherDelegate : public UserInfoFetcher::Delegate {
27 public: 27 public:
28 MockUserInfoFetcherDelegate() {} 28 MockUserInfoFetcherDelegate() {}
29 ~MockUserInfoFetcherDelegate() {} 29 ~MockUserInfoFetcherDelegate() {}
30 MOCK_METHOD1(OnGetUserInfoFailure, 30 MOCK_METHOD1(OnGetUserInfoFailure,
31 void(const GoogleServiceAuthError& error)); 31 void(const GoogleServiceAuthError& error));
32 MOCK_METHOD1(OnGetUserInfoSuccess, void(const DictionaryValue* result)); 32 MOCK_METHOD1(OnGetUserInfoSuccess, void(const base::DictionaryValue* result));
33 }; 33 };
34 34
35 MATCHER_P(MatchDict, expected, "matches DictionaryValue") { 35 MATCHER_P(MatchDict, expected, "matches DictionaryValue") {
36 return arg->Equals(expected); 36 return arg->Equals(expected);
37 } 37 }
38 38
39 class UserInfoFetcherTest : public testing::Test { 39 class UserInfoFetcherTest : public testing::Test {
40 public: 40 public:
41 UserInfoFetcherTest() {} 41 UserInfoFetcherTest() {}
42 net::TestURLFetcherFactory url_factory_; 42 net::TestURLFetcherFactory url_factory_;
(...skipping 12 matching lines...) Expand all
55 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher); 55 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher);
56 } 56 }
57 57
58 TEST_F(UserInfoFetcherTest, SuccessfulFetch) { 58 TEST_F(UserInfoFetcherTest, SuccessfulFetch) {
59 MockUserInfoFetcherDelegate delegate; 59 MockUserInfoFetcherDelegate delegate;
60 UserInfoFetcher fetcher(&delegate, NULL); 60 UserInfoFetcher fetcher(&delegate, NULL);
61 fetcher.Start("access_token"); 61 fetcher.Start("access_token");
62 62
63 // Generate what we expect our result will look like (should match 63 // Generate what we expect our result will look like (should match
64 // parsed kUserInfoResponse). 64 // parsed kUserInfoResponse).
65 scoped_ptr<DictionaryValue> dict(new DictionaryValue()); 65 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
66 dict->SetString("email", "test_user@test.com"); 66 dict->SetString("email", "test_user@test.com");
67 dict->SetBoolean("verified_email", true); 67 dict->SetBoolean("verified_email", true);
68 dict->SetString("hd", "test.com"); 68 dict->SetString("hd", "test.com");
69 69
70 // Fake a successful fetch - should result in the data being parsed and 70 // Fake a successful fetch - should result in the data being parsed and
71 // the values passed off to the success callback. 71 // the values passed off to the success callback.
72 EXPECT_CALL(delegate, OnGetUserInfoSuccess(MatchDict(dict.get()))); 72 EXPECT_CALL(delegate, OnGetUserInfoSuccess(MatchDict(dict.get())));
73 net::TestURLFetcher* url_fetcher = url_factory_.GetFetcherByID(0); 73 net::TestURLFetcher* url_fetcher = url_factory_.GetFetcherByID(0);
74 url_fetcher->set_response_code(net::HTTP_OK); 74 url_fetcher->set_response_code(net::HTTP_OK);
75 url_fetcher->SetResponseString(kUserInfoResponse); 75 url_fetcher->SetResponseString(kUserInfoResponse);
76 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher); 76 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher);
77 } 77 }
78 } // namespace 78 } // namespace
79 79
80 } // namespace policy 80 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/cloud/policy_header_service_unittest.cc ('k') | components/policy/core/common/policy_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698