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

Side by Side Diff: chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed another test. Created 5 years, 3 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
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/rand_util.h" 5 #include "base/rand_util.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/policy/profile_policy_connector_factory.h" 8 #include "chrome/browser/policy/profile_policy_connector_factory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
11 #include "chrome/browser/sync/test/integration/passwords_helper.h" 11 #include "chrome/browser/sync/test/integration/passwords_helper.h"
12 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 12 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
14 #include "chrome/browser/sync/test/integration/sync_test.h" 14 #include "chrome/browser/sync/test/integration/sync_test.h"
15 #include "components/bookmarks/browser/bookmark_node.h" 15 #include "components/bookmarks/browser/bookmark_node.h"
16 #include "components/policy/core/common/mock_configuration_policy_provider.h" 16 #include "components/policy/core/common/mock_configuration_policy_provider.h"
17 #include "components/policy/core/common/policy_map.h" 17 #include "components/policy/core/common/policy_map.h"
18 #include "components/policy/core/common/policy_types.h"
18 #include "policy/policy_constants.h" 19 #include "policy/policy_constants.h"
19 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 20 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "ui/base/layout.h" 22 #include "ui/base/layout.h"
22 23
23 using bookmarks::BookmarkNode; 24 using bookmarks::BookmarkNode;
24 using bookmarks_helper::AddFolder; 25 using bookmarks_helper::AddFolder;
25 using bookmarks_helper::AddURL; 26 using bookmarks_helper::AddURL;
26 using bookmarks_helper::AllModelsMatch; 27 using bookmarks_helper::AllModelsMatch;
27 using bookmarks_helper::AllModelsMatchVerifier; 28 using bookmarks_helper::AllModelsMatchVerifier;
(...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 // Set the ManagedBookmarks policy for the first Profile, 2197 // Set the ManagedBookmarks policy for the first Profile,
2197 // which will add one new managed bookmark. 2198 // which will add one new managed bookmark.
2198 base::DictionaryValue* bookmark = new base::DictionaryValue(); 2199 base::DictionaryValue* bookmark = new base::DictionaryValue();
2199 bookmark->SetString("name", "Managed bookmark"); 2200 bookmark->SetString("name", "Managed bookmark");
2200 bookmark->SetString("url", "youtube.com"); 2201 bookmark->SetString("url", "youtube.com");
2201 base::ListValue* list = new base::ListValue(); 2202 base::ListValue* list = new base::ListValue();
2202 list->Append(bookmark); 2203 list->Append(bookmark);
2203 policy::PolicyMap policy; 2204 policy::PolicyMap policy;
2204 policy.Set(policy::key::kManagedBookmarks, 2205 policy.Set(policy::key::kManagedBookmarks,
2205 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, 2206 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
2206 list, NULL); 2207 policy::POLICY_SOURCE_CLOUD, list, nullptr);
2207 policy_provider_.UpdateChromePolicy(policy); 2208 policy_provider_.UpdateChromePolicy(policy);
2208 base::RunLoop().RunUntilIdle(); 2209 base::RunLoop().RunUntilIdle();
2209 2210
2210 // Now add another user bookmark and wait for it to sync. 2211 // Now add another user bookmark and wait for it to sync.
2211 ASSERT_TRUE(AddURL(0, "Google 2", google_url) != NULL); 2212 ASSERT_TRUE(AddURL(0, "Google 2", google_url) != NULL);
2212 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 2213 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2213 ASSERT_TRUE(AllModelsMatchVerifier()); 2214 ASSERT_TRUE(AllModelsMatchVerifier());
2214 2215
2215 EXPECT_FALSE(GetSyncService(0)->HasUnrecoverableError()); 2216 EXPECT_FALSE(GetSyncService(0)->HasUnrecoverableError());
2216 EXPECT_FALSE(GetSyncService(1)->HasUnrecoverableError()); 2217 EXPECT_FALSE(GetSyncService(1)->HasUnrecoverableError());
2217 2218
2218 // Verify that the managed bookmark exists in the local model of the first 2219 // Verify that the managed bookmark exists in the local model of the first
2219 // Profile, and has a child node. 2220 // Profile, and has a child node.
2220 ASSERT_EQ(1, managed_node0->child_count()); 2221 ASSERT_EQ(1, managed_node0->child_count());
2221 ASSERT_TRUE(managed_node0->IsVisible()); 2222 ASSERT_TRUE(managed_node0->IsVisible());
2222 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); 2223 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url());
2223 2224
2224 // Verify that the second Profile didn't get this node. 2225 // Verify that the second Profile didn't get this node.
2225 ASSERT_EQ(0, managed_node1->child_count()); 2226 ASSERT_EQ(0, managed_node1->child_count());
2226 } 2227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698