OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
| 7 #include <memory> |
7 #include <utility> | 8 #include <utility> |
8 | 9 |
9 #include "base/macros.h" | 10 #include "base/macros.h" |
10 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 16 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
(...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 // Verify that adding a bookmark is observed by the second Profile. | 2201 // Verify that adding a bookmark is observed by the second Profile. |
2201 GURL google_url("http://www.google.com"); | 2202 GURL google_url("http://www.google.com"); |
2202 ASSERT_TRUE(AddURL(0, "Google", google_url) != NULL); | 2203 ASSERT_TRUE(AddURL(0, "Google", google_url) != NULL); |
2203 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 2204 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
2204 ASSERT_TRUE(AllModelsMatchVerifier()); | 2205 ASSERT_TRUE(AllModelsMatchVerifier()); |
2205 ASSERT_EQ(1, bar_node0->child_count()); | 2206 ASSERT_EQ(1, bar_node0->child_count()); |
2206 ASSERT_EQ(1, bar_node1->child_count()); | 2207 ASSERT_EQ(1, bar_node1->child_count()); |
2207 | 2208 |
2208 // Set the ManagedBookmarks policy for the first Profile, | 2209 // Set the ManagedBookmarks policy for the first Profile, |
2209 // which will add one new managed bookmark. | 2210 // which will add one new managed bookmark. |
2210 base::DictionaryValue* bookmark = new base::DictionaryValue(); | 2211 std::unique_ptr<base::DictionaryValue> bookmark(new base::DictionaryValue()); |
2211 bookmark->SetString("name", "Managed bookmark"); | 2212 bookmark->SetString("name", "Managed bookmark"); |
2212 bookmark->SetString("url", "youtube.com"); | 2213 bookmark->SetString("url", "youtube.com"); |
2213 std::unique_ptr<base::ListValue> list(new base::ListValue()); | 2214 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
2214 list->Append(bookmark); | 2215 list->Append(std::move(bookmark)); |
2215 policy::PolicyMap policy; | 2216 policy::PolicyMap policy; |
2216 policy.Set(policy::key::kManagedBookmarks, policy::POLICY_LEVEL_MANDATORY, | 2217 policy.Set(policy::key::kManagedBookmarks, policy::POLICY_LEVEL_MANDATORY, |
2217 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, | 2218 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, |
2218 std::move(list), nullptr); | 2219 std::move(list), nullptr); |
2219 policy_provider_.UpdateChromePolicy(policy); | 2220 policy_provider_.UpdateChromePolicy(policy); |
2220 base::RunLoop().RunUntilIdle(); | 2221 base::RunLoop().RunUntilIdle(); |
2221 | 2222 |
2222 // Now add another user bookmark and wait for it to sync. | 2223 // Now add another user bookmark and wait for it to sync. |
2223 ASSERT_TRUE(AddURL(0, "Google 2", google_url) != NULL); | 2224 ASSERT_TRUE(AddURL(0, "Google 2", google_url) != NULL); |
2224 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 2225 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 // second client. | 2342 // second client. |
2342 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::BOOKMARKS)); | 2343 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::BOOKMARKS)); |
2343 const std::string url_title_2 = "another happy little url"; | 2344 const std::string url_title_2 = "another happy little url"; |
2344 const GURL url_2("https://example.com/second"); | 2345 const GURL url_2("https://example.com/second"); |
2345 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, url_title_2, url_2) != NULL); | 2346 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, url_title_2, url_2) != NULL); |
2346 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::BOOKMARKS)); | 2347 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::BOOKMARKS)); |
2347 ASSERT_TRUE(AwaitAllModelsMatch()); | 2348 ASSERT_TRUE(AwaitAllModelsMatch()); |
2348 ASSERT_EQ(initial_count + 2, CountAllBookmarks(0)); | 2349 ASSERT_EQ(initial_count + 2, CountAllBookmarks(0)); |
2349 ASSERT_EQ(initial_count + 2, CountAllBookmarks(1)); | 2350 ASSERT_EQ(initial_count + 2, CountAllBookmarks(1)); |
2350 } | 2351 } |
OLD | NEW |