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

Side by Side Diff: chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc

Issue 179843002: Make invalidations work for Chrome OS Kiosk Apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync tests Created 6 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/run_loop.h" 5 #include "base/run_loop.h"
6 #include "chrome/browser/invalidation/fake_invalidation_service.h"
6 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h" 7 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h"
7 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 8 #include "chrome/browser/invalidation/invalidation_auth_provider.h"
8 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
9 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" 9 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
10 #include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h"
11 #include "chrome/browser/signin/profile_oauth2_token_service.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
13 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 11 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "google_apis/gaia/google_service_auth_error.h" 12 #include "google_apis/gaia/google_service_auth_error.h"
16 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
17 14
18 namespace invalidation { 15 namespace invalidation {
19 namespace { 16 namespace {
20 17
21 class GCMInvalidationBridgeTest : public ::testing::Test { 18 class GCMInvalidationBridgeTest : public ::testing::Test {
22 protected: 19 protected:
23 GCMInvalidationBridgeTest() {} 20 GCMInvalidationBridgeTest() {}
24 21
25 virtual ~GCMInvalidationBridgeTest() {} 22 virtual ~GCMInvalidationBridgeTest() {}
26 23
27 virtual void SetUp() OVERRIDE { 24 virtual void SetUp() OVERRIDE {
28 TestingProfile::Builder builder; 25 bridge_.reset(new GCMInvalidationBridge(NULL, &auth_provider_));
29 builder.AddTestingFactory(
30 ProfileOAuth2TokenServiceFactory::GetInstance(),
31 FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService);
32 profile_ = builder.Build();
33
34 FakeProfileOAuth2TokenService* token_service =
35 (FakeProfileOAuth2TokenService*)
36 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get());
37 token_service->IssueRefreshTokenForUser("", "refresh_token");
38
39 bridge_.reset(new GCMInvalidationBridge(profile_.get()));
40 26
41 delegate_ = bridge_->CreateDelegate(); 27 delegate_ = bridge_->CreateDelegate();
42 delegate_->Initialize(); 28 delegate_->Initialize();
43 base::RunLoop run_loop; 29 base::RunLoop run_loop;
44 run_loop.RunUntilIdle(); 30 run_loop.RunUntilIdle();
45 } 31 }
46 32
47 public: 33 public:
48 void RegisterFinished(const std::string& registration_id, 34 void RegisterFinished(const std::string& registration_id,
49 gcm::GCMClient::Result result) {} 35 gcm::GCMClient::Result result) {}
50 36
51 void RequestTokenFinished(const GoogleServiceAuthError& error, 37 void RequestTokenFinished(const GoogleServiceAuthError& error,
52 const std::string& token) { 38 const std::string& token) {
53 issued_tokens_.push_back(token); 39 issued_tokens_.push_back(token);
54 request_token_errors_.push_back(error); 40 request_token_errors_.push_back(error);
55 } 41 }
56 42
57 content::TestBrowserThreadBundle thread_bundle_; 43 content::TestBrowserThreadBundle thread_bundle_;
58 scoped_ptr<Profile> profile_; 44 FakeInvalidationAuthProvider auth_provider_;
59 FakeProfileOAuth2TokenService* token_service_;
60 45
61 std::vector<std::string> issued_tokens_; 46 std::vector<std::string> issued_tokens_;
62 std::vector<GoogleServiceAuthError> request_token_errors_; 47 std::vector<GoogleServiceAuthError> request_token_errors_;
63 48
64 scoped_ptr<GCMInvalidationBridge> bridge_; 49 scoped_ptr<GCMInvalidationBridge> bridge_;
65 scoped_ptr<syncer::GCMNetworkChannelDelegate> delegate_; 50 scoped_ptr<syncer::GCMNetworkChannelDelegate> delegate_;
66 }; 51 };
67 52
68 TEST_F(GCMInvalidationBridgeTest, RequestToken) { 53 TEST_F(GCMInvalidationBridgeTest, RequestToken) {
69 // Make sure that call to RequestToken reaches OAuth2TokenService and gets 54 // Make sure that call to RequestToken reaches OAuth2TokenService and gets
(...skipping 25 matching lines...) Expand all
95 EXPECT_EQ("", issued_tokens_[0]); 80 EXPECT_EQ("", issued_tokens_[0]);
96 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, 81 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED,
97 request_token_errors_[0].state()); 82 request_token_errors_[0].state());
98 83
99 EXPECT_NE("", issued_tokens_[1]); 84 EXPECT_NE("", issued_tokens_[1]);
100 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), request_token_errors_[1]); 85 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), request_token_errors_[1]);
101 } 86 }
102 87
103 } // namespace 88 } // namespace
104 } // namespace invalidation 89 } // namespace invalidation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698