Index: chrome/browser/sync/profile_sync_service_session_unittest.cc |
diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc |
index 44d1dfb0c4bb17788b5873f7c3f0e9830924f59a..8d60cbc0a7a26b90ea5f12b54d61c05b1c71c969 100644 |
--- a/chrome/browser/sync/profile_sync_service_session_unittest.cc |
+++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc |
@@ -16,10 +16,12 @@ |
#include "base/stl_util.h" |
#include "base/time.h" |
#include "base/utf_string_conversions.h" |
+ |
#include "chrome/browser/signin/signin_manager.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
#include "chrome/browser/signin/token_service_factory.h" |
#include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
+#include "chrome/browser/sync/glue/change_processor.h" |
#include "chrome/browser/sync/glue/device_info.h" |
#include "chrome/browser/sync/glue/session_change_processor.h" |
#include "chrome/browser/sync/glue/session_data_type_controller.h" |
@@ -32,6 +34,7 @@ |
#include "chrome/browser/sync/profile_sync_service_factory.h" |
#include "chrome/browser/sync/profile_sync_test_util.h" |
#include "chrome/browser/sync/test_profile_sync_service.h" |
+#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/test/base/browser_with_test_window_test.h" |
#include "chrome/test/base/testing_profile.h" |
@@ -40,6 +43,7 @@ |
#include "content/public/browser/notification_registrar.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/test/test_browser_thread.h" |
+#include "content/public/test/test_utils.h" |
#include "google_apis/gaia/gaia_constants.h" |
#include "googleurl/src/gurl.h" |
#include "sync/internal_api/public/base/model_type.h" |
@@ -776,12 +780,12 @@ TEST_F(ProfileSyncServiceSessionTest, TabNodePoolNonEmpty) { |
const size_t num_starting_nodes = 3; |
for (size_t i = 0; i < num_starting_nodes; ++i) { |
- model_associator_->tab_pool_.AddTabNode(i); |
+ model_associator_->tab_pool_.AddTabNode(i, i); |
} |
std::vector<int64> node_ids; |
ASSERT_EQ(num_starting_nodes, model_associator_->tab_pool_.capacity()); |
- ASSERT_FALSE(model_associator_->tab_pool_.empty()); |
+ //ASSERT_FALSE(model_associator_->tab_pool_.empty()); |
ASSERT_TRUE(model_associator_->tab_pool_.full()); |
const size_t num_ids = 10; |
for (size_t i = 0; i < num_ids; ++i) { |
@@ -1180,6 +1184,54 @@ TEST_F(ProfileSyncServiceSessionTest, MissingLocalTabNode) { |
AddTab(browser(), GURL("http://baz2")); |
} |
+void CloseTab(int index) {} |
+ |
+TEST_F(ProfileSyncServiceSessionTest, CheckTabAssociation) { |
+ // Incomplete test currently just verifies that reassociation does not |
+ // cause any errors. |
+ AddTab(browser(), GURL("http://foo1")); |
+ AddTab(browser(), GURL("http://foo2")); |
+ AddTab(browser(), GURL("http://foo3")); |
+ |
+ CreateRootHelper create_root(this); |
+ ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
+ |
+ std::string local_tag = model_associator_->GetCurrentMachineTag(); |
+ change_processor_->StopObserving(); |
+ syncer::SyncError error; |
+ |
+ error = model_associator_->DisassociateModels(); |
+ ASSERT_FALSE(error.IsSet()); |
+ |
+ content::WindowedNotificationObserver tab_close_observer( |
+ content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
+ content::NotificationService::AllSources()); |
+ browser()->tab_strip_model() |
+ ->CloseWebContentsAt(0, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
+ tab_close_observer.Wait(); |
+ |
+ change_processor_->StartObserving(); |
+ { |
+ // Delete the first sync tab node. |
+ std::string tab_tag = TabNodePool::TabIdToTag(local_tag, 0); |
+ |
+ syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
+ syncer::ReadNode root(&trans); |
+ root.InitByTagLookup(syncer::ModelTypeToRootTag(syncer::SESSIONS)); |
+ syncer::WriteNode tab_node(&trans); |
+ ASSERT_EQ(syncer::BaseNode::INIT_OK, |
+ tab_node.InitByClientTagLookup(syncer::SESSIONS, tab_tag)); |
+ tab_node.Tombstone(); |
+ } |
+ error = model_associator_->AssociateModels(NULL, NULL); |
+ ASSERT_FALSE(error.IsSet()); |
+ |
+ // Add some more tabs to ensure we don't conflict with the pre-existing tab |
+ // node. |
+ AddTab(browser(), GURL("http://baz1")); |
+ AddTab(browser(), GURL("http://baz2")); |
+} |
+ |
TEST_F(ProfileSyncServiceSessionTest, Favicons) { |
CreateRootHelper create_root(this); |
ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |