OLD | NEW |
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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
26 | 26 |
27 using testing::Mock; | 27 using testing::Mock; |
28 using testing::_; | 28 using testing::_; |
29 | 29 |
30 class ChromeBookmarkClientTest : public testing::Test { | 30 class ChromeBookmarkClientTest : public testing::Test { |
31 public: | 31 public: |
32 ChromeBookmarkClientTest() : client_(NULL), model_(NULL) {} | 32 ChromeBookmarkClientTest() : client_(NULL), model_(NULL) {} |
33 virtual ~ChromeBookmarkClientTest() {} | 33 virtual ~ChromeBookmarkClientTest() {} |
34 | 34 |
35 virtual void SetUp() OVERRIDE { | 35 virtual void SetUp() override { |
36 prefs_ = profile_.GetTestingPrefService(); | 36 prefs_ = profile_.GetTestingPrefService(); |
37 ASSERT_FALSE(prefs_->HasPrefPath(bookmarks::prefs::kManagedBookmarks)); | 37 ASSERT_FALSE(prefs_->HasPrefPath(bookmarks::prefs::kManagedBookmarks)); |
38 | 38 |
39 prefs_->SetManagedPref(bookmarks::prefs::kManagedBookmarks, | 39 prefs_->SetManagedPref(bookmarks::prefs::kManagedBookmarks, |
40 CreateTestTree()); | 40 CreateTestTree()); |
41 ResetModel(); | 41 ResetModel(); |
42 | 42 |
43 // The managed node always exists. | 43 // The managed node always exists. |
44 ASSERT_TRUE(client_->managed_node()); | 44 ASSERT_TRUE(client_->managed_node()); |
45 ASSERT_TRUE(client_->managed_node()->parent() == model_->root_node()); | 45 ASSERT_TRUE(client_->managed_node()->parent() == model_->root_node()); |
46 EXPECT_NE(-1, model_->root_node()->GetIndexOf(client_->managed_node())); | 46 EXPECT_NE(-1, model_->root_node()->GetIndexOf(client_->managed_node())); |
47 } | 47 } |
48 | 48 |
49 virtual void TearDown() OVERRIDE { | 49 virtual void TearDown() override { |
50 model_->RemoveObserver(&observer_); | 50 model_->RemoveObserver(&observer_); |
51 } | 51 } |
52 | 52 |
53 void ResetModel() { | 53 void ResetModel() { |
54 profile_.CreateBookmarkModel(false); | 54 profile_.CreateBookmarkModel(false); |
55 model_ = BookmarkModelFactory::GetForProfile(&profile_); | 55 model_ = BookmarkModelFactory::GetForProfile(&profile_); |
56 test::WaitForBookmarkModelToLoad(model_); | 56 test::WaitForBookmarkModelToLoad(model_); |
57 model_->AddObserver(&observer_); | 57 model_->AddObserver(&observer_); |
58 client_ = ChromeBookmarkClientFactory::GetForProfile(&profile_); | 58 client_ = ChromeBookmarkClientFactory::GetForProfile(&profile_); |
59 DCHECK(client_); | 59 DCHECK(client_); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 const BookmarkNode* managed_node = client_->managed_node()->GetChild(0); | 279 const BookmarkNode* managed_node = client_->managed_node()->GetChild(0); |
280 ASSERT_TRUE(managed_node); | 280 ASSERT_TRUE(managed_node); |
281 | 281 |
282 std::vector<const BookmarkNode*> nodes; | 282 std::vector<const BookmarkNode*> nodes; |
283 EXPECT_FALSE(client_->HasDescendantsOfManagedNode(nodes)); | 283 EXPECT_FALSE(client_->HasDescendantsOfManagedNode(nodes)); |
284 nodes.push_back(user_node); | 284 nodes.push_back(user_node); |
285 EXPECT_FALSE(client_->HasDescendantsOfManagedNode(nodes)); | 285 EXPECT_FALSE(client_->HasDescendantsOfManagedNode(nodes)); |
286 nodes.push_back(managed_node); | 286 nodes.push_back(managed_node); |
287 EXPECT_TRUE(client_->HasDescendantsOfManagedNode(nodes)); | 287 EXPECT_TRUE(client_->HasDescendantsOfManagedNode(nodes)); |
288 } | 288 } |
OLD | NEW |