| OLD | NEW | 
|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 entry. | 3 // found in the LICENSE entry. | 
| 4 | 4 | 
| 5 #include "base/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" | 
| 6 #include "base/scoped_temp_dir.h" | 6 #include "base/scoped_temp_dir.h" | 
| 7 #include "base/test/test_file_util.h" | 7 #include "base/test/test_file_util.h" | 
| 8 #include "base/waitable_event.h" | 8 #include "base/waitable_event.h" | 
| 9 #include "chrome/browser/sync/engine/all_status.h" | 9 #include "chrome/browser/sync/engine/all_status.h" | 
| 10 #include "chrome/browser/sync/engine/auth_watcher.h" | 10 #include "chrome/browser/sync/engine/auth_watcher.h" | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 79   virtual void SetUp() { | 79   virtual void SetUp() { | 
| 80     metadb_.SetUp(); | 80     metadb_.SetUp(); | 
| 81     connection_.reset(new MockConnectionManager(metadb_.manager(), | 81     connection_.reset(new MockConnectionManager(metadb_.manager(), | 
| 82                                                 metadb_.name())); | 82                                                 metadb_.name())); | 
| 83     // Mock out data that would normally be sent back from a server. | 83     // Mock out data that would normally be sent back from a server. | 
| 84     connection()->SetAuthenticationResponseInfo(kValidAuthToken, | 84     connection()->SetAuthenticationResponseInfo(kValidAuthToken, | 
| 85         kUserDisplayName, kUserDisplayEmail, "ID"); | 85         kUserDisplayName, kUserDisplayEmail, "ID"); | 
| 86     allstatus_.reset(new AllStatus()); | 86     allstatus_.reset(new AllStatus()); | 
| 87     user_settings_.reset(new UserSettings()); | 87     user_settings_.reset(new UserSettings()); | 
| 88     ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 88     ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 
| 89     PathString user_settings_path = temp_dir_.path().value() + kUserSettingsDB; | 89     FilePath user_settings_path = temp_dir_.path().Append(kUserSettingsDB); | 
| 90     user_settings_->Init(user_settings_path); | 90     user_settings_->Init(user_settings_path); | 
| 91     gaia_auth_ = new GaiaAuthMockForAuthWatcher(); | 91     gaia_auth_ = new GaiaAuthMockForAuthWatcher(); | 
| 92     talk_mediator_.reset(new TalkMediatorImpl()); | 92     talk_mediator_.reset(new TalkMediatorImpl()); | 
| 93     auth_watcher_ = new AuthWatcher(metadb_.manager(), connection_.get(), | 93     auth_watcher_ = new AuthWatcher(metadb_.manager(), connection_.get(), | 
| 94         allstatus_.get(), kTestUserAgent, kTestServiceId, kTestGaiaURL, | 94         allstatus_.get(), kTestUserAgent, kTestServiceId, kTestGaiaURL, | 
| 95         user_settings_.get(), gaia_auth_, talk_mediator_.get()); | 95         user_settings_.get(), gaia_auth_, talk_mediator_.get()); | 
| 96     authwatcher_hookup_.reset(NewEventListenerHookup(auth_watcher_->channel(), | 96     authwatcher_hookup_.reset(NewEventListenerHookup(auth_watcher_->channel(), | 
| 97         this, &AuthWatcherTest::HandleAuthWatcherEvent)); | 97         this, &AuthWatcherTest::HandleAuthWatcherEvent)); | 
| 98   } | 98   } | 
| 99 | 99 | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 202   EXPECT_EQ(AuthWatcherEvent::SERVICE_AUTH_FAILED, ConsumeNextEvent()); | 202   EXPECT_EQ(AuthWatcherEvent::SERVICE_AUTH_FAILED, ConsumeNextEvent()); | 
| 203 } | 203 } | 
| 204 | 204 | 
| 205 TEST_F(AuthWatcherTest, AuthenticateWithTokenSuccess) { | 205 TEST_F(AuthWatcherTest, AuthenticateWithTokenSuccess) { | 
| 206   auth_watcher()->AuthenticateWithToken(kTestEmail, kValidAuthToken); | 206   auth_watcher()->AuthenticateWithToken(kTestEmail, kValidAuthToken); | 
| 207   EXPECT_EQ(AuthWatcherEvent::AUTH_SUCCEEDED, ConsumeNextEvent()); | 207   EXPECT_EQ(AuthWatcherEvent::AUTH_SUCCEEDED, ConsumeNextEvent()); | 
| 208   EXPECT_EQ(kUserDisplayEmail, user_email()); | 208   EXPECT_EQ(kUserDisplayEmail, user_email()); | 
| 209 } | 209 } | 
| 210 | 210 | 
| 211 }  // namespace browser_sync | 211 }  // namespace browser_sync | 
| OLD | NEW | 
|---|