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

Side by Side Diff: chrome/browser/bookmarks/chrome_bookmark_client_unittest.cc

Issue 306293006: Introduce ChromeBookmarkClientFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@364865
Patch Set: Add missing dependency in components/policy/policy_browser.gypi Created 6 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/bookmarks/chrome_bookmark_client.h" 5 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
13 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
13 #include "chrome/test/base/testing_pref_service_syncable.h" 14 #include "chrome/test/base/testing_pref_service_syncable.h"
14 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
15 #include "components/bookmarks/browser/bookmark_model.h" 16 #include "components/bookmarks/browser/bookmark_model.h"
16 #include "components/bookmarks/browser/bookmark_node.h" 17 #include "components/bookmarks/browser/bookmark_node.h"
17 #include "components/bookmarks/common/bookmark_pref_names.h" 18 #include "components/bookmarks/common/bookmark_pref_names.h"
18 #include "components/bookmarks/test/bookmark_test_helpers.h" 19 #include "components/bookmarks/test/bookmark_test_helpers.h"
19 #include "components/bookmarks/test/mock_bookmark_model_observer.h" 20 #include "components/bookmarks/test/mock_bookmark_model_observer.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 21 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "grit/components_strings.h" 22 #include "grit/components_strings.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 20 matching lines...) Expand all
43 ASSERT_TRUE(client_->managed_node()->parent() == model_->root_node()); 44 ASSERT_TRUE(client_->managed_node()->parent() == model_->root_node());
44 EXPECT_NE(-1, model_->root_node()->GetIndexOf(client_->managed_node())); 45 EXPECT_NE(-1, model_->root_node()->GetIndexOf(client_->managed_node()));
45 } 46 }
46 47
47 virtual void TearDown() OVERRIDE { 48 virtual void TearDown() OVERRIDE {
48 model_->RemoveObserver(&observer_); 49 model_->RemoveObserver(&observer_);
49 } 50 }
50 51
51 void ResetModel() { 52 void ResetModel() {
52 profile_.CreateBookmarkModel(false); 53 profile_.CreateBookmarkModel(false);
53 client_ = 54 model_ = BookmarkModelFactory::GetForProfile(&profile_);
54 BookmarkModelFactory::GetChromeBookmarkClientForProfile(&profile_);
55 ASSERT_TRUE(client_);
56 model_ = client_->model();
57 test::WaitForBookmarkModelToLoad(model_); 55 test::WaitForBookmarkModelToLoad(model_);
58 model_->AddObserver(&observer_); 56 model_->AddObserver(&observer_);
57 client_ = ChromeBookmarkClientFactory::GetForProfile(&profile_);
58 DCHECK(client_);
59 } 59 }
60 60
61 static base::DictionaryValue* CreateBookmark(const std::string& title, 61 static base::DictionaryValue* CreateBookmark(const std::string& title,
62 const std::string& url) { 62 const std::string& url) {
63 EXPECT_TRUE(GURL(url).is_valid()); 63 EXPECT_TRUE(GURL(url).is_valid());
64 base::DictionaryValue* dict = new base::DictionaryValue(); 64 base::DictionaryValue* dict = new base::DictionaryValue();
65 dict->SetString("name", title); 65 dict->SetString("name", title);
66 dict->SetString("url", GURL(url).spec()); 66 dict->SetString("url", GURL(url).spec());
67 return dict; 67 return dict;
68 } 68 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 const BookmarkNode* managed_node = client_->managed_node()->GetChild(0); 275 const BookmarkNode* managed_node = client_->managed_node()->GetChild(0);
276 ASSERT_TRUE(managed_node); 276 ASSERT_TRUE(managed_node);
277 277
278 std::vector<const BookmarkNode*> nodes; 278 std::vector<const BookmarkNode*> nodes;
279 EXPECT_FALSE(client_->HasDescendantsOfManagedNode(nodes)); 279 EXPECT_FALSE(client_->HasDescendantsOfManagedNode(nodes));
280 nodes.push_back(user_node); 280 nodes.push_back(user_node);
281 EXPECT_FALSE(client_->HasDescendantsOfManagedNode(nodes)); 281 EXPECT_FALSE(client_->HasDescendantsOfManagedNode(nodes));
282 nodes.push_back(managed_node); 282 nodes.push_back(managed_node);
283 EXPECT_TRUE(client_->HasDescendantsOfManagedNode(nodes)); 283 EXPECT_TRUE(client_->HasDescendantsOfManagedNode(nodes));
284 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698