summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 01:38:35 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 01:38:35 +0000
commit265d8c32bd4dbb4b1a142c8204b434a03e8a8c8f (patch)
tree105095d5eead4db62bbf60ed0b3f1d243b202e76 /chrome/test
parent8b20191a72da085319a68e4953e9f2b355218825 (diff)
downloadchromium_src-265d8c32bd4dbb4b1a142c8204b434a03e8a8c8f.zip
chromium_src-265d8c32bd4dbb4b1a142c8204b434a03e8a8c8f.tar.gz
chromium_src-265d8c32bd4dbb4b1a142c8204b434a03e8a8c8f.tar.bz2
Revert 58778 - New authorization framework for sync.
To quote chron's original patch (http://codereview.chromium.org/3148036/show) <blockquote> This patch removes: authenticator.cc, auth_watcher.cc removes calls to user_settings.cc, removes an authenticate PB request to the server, and moves token storage into the Chrome TokenService. This patch introduces the SigninManager, which is an interim solution for user management prior to moving the system into chrome. Other changes include removing the dependency on the sync backend to be running while the sync wizard is intially displayed. This means that the backend can be brought up in response to credentials becoming available. The backend now is always provided credentials on startup. If an auth error occurs, it propogates it up via a notification. Some event handlers were removed and streamlined for more straightforward sync system startup. </blockquote> BUG=51001, 50293, 35158 TEST=Unit tests && Start up sync, log in, log out, run with expired credentials, run with new gaia credentials, run with gaia credentials updated while system is syncing. Try logging in with incorrect username. Trigger CAPTCHA. Try logging out and in repeatedly. Check about:sync works. Try going offline and back online again. Expire gaia credentials and try renewing it with the UI dialog. Review URL: http://codereview.chromium.org/3305003 TBR=johnnyg@chromium.org Review URL: http://codereview.chromium.org/3310019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58782 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/live_sync/live_sync_test.cc10
-rw-r--r--chrome/test/live_sync/offline_sync_test.cc29
-rw-r--r--chrome/test/live_sync/profile_sync_service_test_harness.cc71
-rw-r--r--chrome/test/live_sync/profile_sync_service_test_harness.h12
-rw-r--r--chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc31
-rw-r--r--chrome/test/profile_mock.h1
-rw-r--r--chrome/test/sync/engine/mock_connection_manager.cc2
-rw-r--r--chrome/test/sync/engine/syncer_command_test.h5
-rw-r--r--chrome/test/testing_profile.cc5
-rw-r--r--chrome/test/testing_profile.h3
10 files changed, 73 insertions, 96 deletions
diff --git a/chrome/test/live_sync/live_sync_test.cc b/chrome/test/live_sync/live_sync_test.cc
index 9fc8598..5ff3e74 100644
--- a/chrome/test/live_sync/live_sync_test.cc
+++ b/chrome/test/live_sync/live_sync_test.cc
@@ -22,7 +22,6 @@
#include "chrome/test/testing_browser_process.h"
#include "googleurl/src/gurl.h"
#include "net/base/escape.h"
-#include "net/base/network_change_notifier.h"
#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/proxy/proxy_service.h"
@@ -232,10 +231,6 @@ void LiveSyncTest::SetUpInProcessBrowserTestFixture() {
// Without this, running the test case on Linux causes an error as we make an
// external DNS lookup of "ocsp.thawte.com".
resolver->AllowDirectLookup("*.thawte.com");
- // The new XMPP cert seems to use crl.geotrust.com on Linux.
- resolver->AllowDirectLookup("*.geotrust.com");
- // SSL chain.
- resolver->AllowDirectLookup("*.gstatic.com");
mock_host_resolver_override_.reset(
new net::ScopedDefaultHostResolverProc(resolver));
}
@@ -260,12 +255,10 @@ void LiveSyncTest::TearDownLocalTestServer() {
ASSERT_TRUE(test_server_.Stop());
}
+
void LiveSyncTest::EnableNetwork(Profile* profile) {
SetProxyConfig(profile->GetRequestContext(),
net::ProxyConfig::CreateDirect());
- // Bugs: http://crbug.com/53857
- // http://crbug.com/53858
- net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
}
void LiveSyncTest::DisableNetwork(Profile* profile) {
@@ -274,7 +267,6 @@ void LiveSyncTest::DisableNetwork(Profile* profile) {
net::ProxyConfig config;
config.proxy_rules().ParseFromString("http=127.0.0.1:0");
SetProxyConfig(profile->GetRequestContext(), config);
- net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
}
bool LiveSyncTest::EnsureSyncServerConfiguration() {
diff --git a/chrome/test/live_sync/offline_sync_test.cc b/chrome/test/live_sync/offline_sync_test.cc
new file mode 100644
index 0000000..c64df34
--- /dev/null
+++ b/chrome/test/live_sync/offline_sync_test.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/profile.h"
+#include "chrome/common/net/gaia/google_service_auth_error.h"
+#include "chrome/test/live_sync/live_sync_test.h"
+#include "chrome/test/live_sync/profile_sync_service_test_harness.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+class OfflineSyncTest : public LiveSyncTest {
+ public:
+ OfflineSyncTest() : LiveSyncTest(LiveSyncTest::SINGLE_CLIENT) {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(OfflineSyncTest);
+};
+
+IN_PROC_BROWSER_TEST_F(OfflineSyncTest, OfflineStart) {
+ ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
+ DisableNetwork(GetProfile(0));
+
+ EXPECT_FALSE(GetClient(0)->SetupSync());
+ EXPECT_EQ(GoogleServiceAuthError::CONNECTION_FAILED,
+ GetClient(0)->service()->GetAuthError().state());
+
+ EnableNetwork(GetProfile(0));
+ EXPECT_TRUE(GetClient(0)->RetryAuthentication());
+}
diff --git a/chrome/test/live_sync/profile_sync_service_test_harness.cc b/chrome/test/live_sync/profile_sync_service_test_harness.cc
index b49bf56..12448da 100644
--- a/chrome/test/live_sync/profile_sync_service_test_harness.cc
+++ b/chrome/test/live_sync/profile_sync_service_test_harness.cc
@@ -7,11 +7,9 @@
#include "chrome/browser/defaults.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
-#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/sync/glue/sync_backend_host.h"
#include "chrome/browser/sync/sessions/session_state.h"
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/net/gaia/google_service_auth_error.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/live_sync/profile_sync_service_test_harness.h"
@@ -86,8 +84,7 @@ bool StateChangeTimeoutEvent::Abort() {
ProfileSyncServiceTestHarness::ProfileSyncServiceTestHarness(Profile* p,
const std::string& username, const std::string& password, int id)
- : wait_state_(WAITING_FOR_ON_BACKEND_INITIALIZED),
- profile_(p), service_(NULL),
+ : wait_state_(WAITING_FOR_ON_AUTH_ERROR), profile_(p), service_(NULL),
last_status_(kInvalidStatus),
last_timestamp_(0),
min_timestamp_needed_(kMinTimestampNeededNone),
@@ -98,11 +95,15 @@ ProfileSyncServiceTestHarness::ProfileSyncServiceTestHarness(Profile* p,
}
bool ProfileSyncServiceTestHarness::SetupSync() {
- service_ = profile_->GetProfileSyncService("");
+ service_ = profile_->GetProfileSyncService();
+ service_->StartUp();
service_->AddObserver(this);
- service_->signin_.StartSignIn(username_, password_, "", "");
+ return WaitForServiceInit(false);
+}
- return WaitForServiceInit();
+bool ProfileSyncServiceTestHarness::RetryAuthentication() {
+ wait_state_ = WAITING_FOR_ON_BACKEND_INITIALIZED;
+ return WaitForServiceInit(true);
}
void ProfileSyncServiceTestHarness::SignalStateCompleteWithNextState(
@@ -120,6 +121,11 @@ bool ProfileSyncServiceTestHarness::RunStateChangeMachine() {
WaitState state = wait_state_;
ProfileSyncService::Status status(service_->QueryDetailedSyncStatus());
switch (wait_state_) {
+ case WAITING_FOR_ON_AUTH_ERROR: {
+ LogClientInfo("WAITING_FOR_ON_AUTH_ERROR");
+ SignalStateCompleteWithNextState(WAITING_FOR_ON_BACKEND_INITIALIZED);
+ break;
+ }
case WAITING_FOR_ON_BACKEND_INITIALIZED: {
LogClientInfo("WAITING_FOR_ON_BACKEND_INITIALIZED");
if (service_->GetAuthError().state() != GoogleServiceAuthError::NONE) {
@@ -137,21 +143,6 @@ bool ProfileSyncServiceTestHarness::RunStateChangeMachine() {
}
break;
}
- case WAITING_FOR_SERVER_REACHABLE: {
- LogClientInfo("WAITING_FOR_SERVER_REACHABLE");
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
- if (!status.server_reachable) {
- break;
- }
- if (service()->backend()->HasUnsyncedItems() ||
- snap->has_more_to_sync || snap->unsynced_count != 0) {
- SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH);
- break;
- }
- last_timestamp_ = snap->max_local_timestamp;
- SignalStateCompleteWithNextState(FULLY_SYNCED);
- break;
- }
case WAITING_FOR_SYNC_TO_FINISH: {
LogClientInfo("WAITING_FOR_SYNC_TO_FINISH");
const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
@@ -160,10 +151,7 @@ bool ProfileSyncServiceTestHarness::RunStateChangeMachine() {
// be a sufficient condition for sync to have completed. However, the
// additional check of snap->unsynced_count is required due to
// http://crbug.com/48989.
- if (service()->backend()->HasUnsyncedItems() ||
- snap->has_more_to_sync || snap->unsynced_count != 0) {
- if (!status.server_reachable)
- SignalStateCompleteWithNextState(WAITING_FOR_SERVER_REACHABLE);
+ if (snap->has_more_to_sync || snap->unsynced_count != 0) {
break;
}
EXPECT_LE(last_timestamp_, snap->max_local_timestamp);
@@ -298,10 +286,18 @@ bool ProfileSyncServiceTestHarness::AwaitStatusChangeWithTimeout(
return timeout_signal->Abort();
}
-bool ProfileSyncServiceTestHarness::WaitForServiceInit() {
+bool ProfileSyncServiceTestHarness::WaitForServiceInit(bool is_auth_retry) {
LogClientInfo("WaitForServiceInit");
+ if (!is_auth_retry) {
+ // Wait for the OnAuthError() callback.
+ EXPECT_EQ(wait_state_, WAITING_FOR_ON_AUTH_ERROR);
+ EXPECT_TRUE(AwaitStatusChangeWithTimeout(30,
+ "Waiting for the OnAuthError() callback.")) <<
+ "OnAuthError() not seen after 30 seconds.";
+ }
- // Wait for the OnBackendInitialized() callback.
+ // Enter GAIA credentials and wait for the OnBackendInitialized() callback.
+ service_->backend()->Authenticate(username_, password_, std::string());
EXPECT_EQ(wait_state_, WAITING_FOR_ON_BACKEND_INITIALIZED);
EXPECT_TRUE(AwaitStatusChangeWithTimeout(30,
"Waiting for OnBackendInitialized().")) <<
@@ -311,13 +307,15 @@ bool ProfileSyncServiceTestHarness::WaitForServiceInit() {
return false;
}
- // Choose datatypes to be synced.
- syncable::ModelTypeSet set;
- for (int i = syncable::FIRST_REAL_MODEL_TYPE;
- i < syncable::MODEL_TYPE_COUNT; ++i) {
- set.insert(syncable::ModelTypeFromInt(i));
+ // Choose datatypes to be synced. Note: This is unnecessary on Chrome OS.
+ if (!browser_defaults::kBootstrapSyncAuthentication) {
+ syncable::ModelTypeSet set;
+ for (int i = syncable::FIRST_REAL_MODEL_TYPE;
+ i < syncable::MODEL_TYPE_COUNT; ++i) {
+ set.insert(syncable::ModelTypeFromInt(i));
+ }
+ service_->OnUserChoseDatatypes(true, set);
}
- service_->OnUserChoseDatatypes(true, set);
// Wait for notifications_enabled to be set to true.
EXPECT_EQ(wait_state_, WAITING_FOR_NOTIFICATIONS_ENABLED);
@@ -331,10 +329,7 @@ bool ProfileSyncServiceTestHarness::WaitForServiceInit() {
const SyncSessionSnapshot*
ProfileSyncServiceTestHarness::GetLastSessionSnapshot() const {
EXPECT_FALSE(service_ == NULL) << "Sync service has not yet been set up.";
- if (service_->backend()) {
- return service_->backend()->GetLastSessionSnapshot();
- }
- return NULL;
+ return service_->backend()->GetLastSessionSnapshot();
}
void ProfileSyncServiceTestHarness::LogClientInfo(std::string message) {
diff --git a/chrome/test/live_sync/profile_sync_service_test_harness.h b/chrome/test/live_sync/profile_sync_service_test_harness.h
index 34cfde3..3b32930 100644
--- a/chrome/test/live_sync/profile_sync_service_test_harness.h
+++ b/chrome/test/live_sync/profile_sync_service_test_harness.h
@@ -31,6 +31,10 @@ class ProfileSyncServiceTestHarness : public ProfileSyncServiceObserver {
// authenticated, and we are ready to process changes.
bool SetupSync();
+ // Retries a sync setup when the previous attempt was aborted by an
+ // authentication failure.
+ bool RetryAuthentication();
+
// ProfileSyncServiceObserver implementation.
virtual void OnStateChanged();
@@ -75,16 +79,16 @@ class ProfileSyncServiceTestHarness : public ProfileSyncServiceObserver {
friend class StateChangeTimeoutEvent;
enum WaitState {
+ // The sync client awaits the OnAuthError() callback.
+ WAITING_FOR_ON_AUTH_ERROR = 0,
// The sync client awaits the OnBackendInitialized() callback.
- WAITING_FOR_ON_BACKEND_INITIALIZED = 0,
+ WAITING_FOR_ON_BACKEND_INITIALIZED,
// The sync client is waiting for notifications_enabled to become true.
WAITING_FOR_NOTIFICATIONS_ENABLED,
// The sync client is waiting for an ongoing sync cycle to complete.
WAITING_FOR_SYNC_TO_FINISH,
// The sync client anticipates incoming updates leading to a new sync cycle.
WAITING_FOR_UPDATES,
- // The sync client is waiting for server_reachable to become true.
- WAITING_FOR_SERVER_REACHABLE,
// The sync client is fully synced and there are no pending updates.
FULLY_SYNCED,
// An authentication error has occurred.
@@ -106,7 +110,7 @@ class ProfileSyncServiceTestHarness : public ProfileSyncServiceObserver {
// Returns true if the service initialized correctly. Set is_auth_retry to
// true when calling this method second time after an authentication failure.
- bool WaitForServiceInit();
+ bool WaitForServiceInit(bool is_auth_retry);
// Logs message with relevant info about client's sync state (if available).
void LogClientInfo(std::string message);
diff --git a/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc
index bc66917..c4cc585 100644
--- a/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc
+++ b/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc
@@ -4,37 +4,6 @@
#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
-// TODO(rsimha): Debug the flakiness of this with fred. http://crbug.com/53858
-IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest,
- FAILS_OfflineToOnline) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- DisableNetwork(GetProfile(0));
-
- BookmarkModel* bm = GetBookmarkModel(0);
- BookmarkModelVerifier* v = verifier_helper();
-
- const BookmarkNode* top = v->AddGroup(bm, bm->other_node(), 0, L"top");
- v->SetTitle(bm, top, L"title");
-
-
- EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Offline state change."));
- {
- ProfileSyncService::Status status(
- GetClient(0)->service()->QueryDetailedSyncStatus());
- EXPECT_EQ(status.summary, ProfileSyncService::Status::OFFLINE_UNSYNCED);
- }
-
- EnableNetwork(GetProfile(0));
- {
- EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Commit changes."));
- ProfileSyncService::Status status(
- GetClient(0)->service()->QueryDetailedSyncStatus());
- EXPECT_EQ(status.summary, ProfileSyncService::Status::READY);
- v->ExpectMatch(bm);
- }
-}
-
IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, Sanity) {
ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
BookmarkModel* bm = GetBookmarkModel(0);
diff --git a/chrome/test/profile_mock.h b/chrome/test/profile_mock.h
index b3b0dcf..67f7ee2 100644
--- a/chrome/test/profile_mock.h
+++ b/chrome/test/profile_mock.h
@@ -18,7 +18,6 @@ class ProfileMock : public TestingProfile {
MOCK_METHOD1(GetWebDataService, WebDataService*(ServiceAccessType access));
MOCK_METHOD0(GetPersonalDataManager, PersonalDataManager*());
MOCK_METHOD1(GetPasswordStore, PasswordStore* (ServiceAccessType access));
- MOCK_METHOD0(GetTokenService, TokenService*());
};
#endif // CHROME_TEST_PROFILE_MOCK_H__
diff --git a/chrome/test/sync/engine/mock_connection_manager.cc b/chrome/test/sync/engine/mock_connection_manager.cc
index 24ad1f2..bfba668 100644
--- a/chrome/test/sync/engine/mock_connection_manager.cc
+++ b/chrome/test/sync/engine/mock_connection_manager.cc
@@ -33,7 +33,7 @@ using syncable::WriteTransaction;
MockConnectionManager::MockConnectionManager(DirectoryManager* dirmgr,
const string& name)
- : ServerConnectionManager("unused", 0, false, "version"),
+ : ServerConnectionManager("unused", 0, false, "version", "id"),
conflict_all_commits_(false),
conflict_n_commits_(0),
next_new_id_(10000),
diff --git a/chrome/test/sync/engine/syncer_command_test.h b/chrome/test/sync/engine/syncer_command_test.h
index 02ea57d..eed8def 100644
--- a/chrome/test/sync/engine/syncer_command_test.h
+++ b/chrome/test/sync/engine/syncer_command_test.h
@@ -48,9 +48,6 @@ class SyncerCommandTestWithParam : public testing::TestWithParam<T>,
virtual void OnShouldStopSyncingPermanently() {
FAIL() << "Shouldn't be forced to stop syncing.";
}
- virtual void SignalUpdatedToken(const std::string& token) {
- FAIL() << "Should never update token.";
- }
// ModelSafeWorkerRegistrar implementation.
virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) {
@@ -94,7 +91,7 @@ class SyncerCommandTestWithParam : public testing::TestWithParam<T>,
void ResetContext() {
context_.reset(new sessions::SyncSessionContext(
- mock_server_.get(), syncdb_->manager(), registrar()));
+ mock_server_.get(), NULL, syncdb_->manager(), registrar()));
context_->set_account_name(syncdb_->name());
ClearSession();
}
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
index 6fd04fc..c6ad9b3 100644
--- a/chrome/test/testing_profile.cc
+++ b/chrome/test/testing_profile.cc
@@ -453,11 +453,6 @@ TokenService* TestingProfile::GetTokenService() {
}
ProfileSyncService* TestingProfile::GetProfileSyncService() {
- return GetProfileSyncService("");
-}
-
-ProfileSyncService* TestingProfile::GetProfileSyncService(
- const std::string& cros_user) {
if (!profile_sync_service_.get()) {
// Use a NiceMock here since we are really using the mock as a
// fake. Test cases that want to set expectations on a
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index d75b7c1..6399692 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -224,7 +224,6 @@ class TestingProfile : public Profile {
virtual void InitExtensions() {}
virtual void InitWebResources() {}
virtual NTPResourceCache* GetNTPResourceCache();
-
virtual DesktopNotificationService* GetDesktopNotificationService();
virtual BackgroundContentsService* GetBackgroundContentsService() {
return NULL;
@@ -253,8 +252,6 @@ class TestingProfile : public Profile {
// Creates and initializes a profile sync service if the tests require one.
virtual TokenService* GetTokenService();
virtual ProfileSyncService* GetProfileSyncService();
- virtual ProfileSyncService* GetProfileSyncService(
- const std::string& cros_notes);
virtual CloudPrintProxyService* GetCloudPrintProxyService() { return NULL; }
virtual ChromeBlobStorageContext* GetBlobStorageContext() {