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 "components/bookmarks/browser/bookmark_utils.h" | 5 #include "components/bookmarks/browser/bookmark_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 class BookmarkUtilsTest : public testing::Test, | 25 class BookmarkUtilsTest : public testing::Test, |
26 public BaseBookmarkModelObserver { | 26 public BaseBookmarkModelObserver { |
27 public: | 27 public: |
28 BookmarkUtilsTest() | 28 BookmarkUtilsTest() |
29 : grouped_changes_beginning_count_(0), | 29 : grouped_changes_beginning_count_(0), |
30 grouped_changes_ended_count_(0) {} | 30 grouped_changes_ended_count_(0) {} |
31 virtual ~BookmarkUtilsTest() {} | 31 virtual ~BookmarkUtilsTest() {} |
32 | 32 |
33 // Copy and paste is not yet supported on iOS. http://crbug.com/228147 | 33 // Copy and paste is not yet supported on iOS. http://crbug.com/228147 |
34 #if !defined(OS_IOS) | 34 #if !defined(OS_IOS) |
35 virtual void TearDown() OVERRIDE { | 35 virtual void TearDown() override { |
36 ui::Clipboard::DestroyClipboardForCurrentThread(); | 36 ui::Clipboard::DestroyClipboardForCurrentThread(); |
37 } | 37 } |
38 #endif // !defined(OS_IOS) | 38 #endif // !defined(OS_IOS) |
39 | 39 |
40 // Certain user actions require multiple changes to the bookmark model, | 40 // Certain user actions require multiple changes to the bookmark model, |
41 // however these modifications need to be atomic for the undo framework. The | 41 // however these modifications need to be atomic for the undo framework. The |
42 // BaseBookmarkModelObserver is used to inform the boundaries of the user | 42 // BaseBookmarkModelObserver is used to inform the boundaries of the user |
43 // action. For example, when multiple bookmarks are cut to the clipboard we | 43 // action. For example, when multiple bookmarks are cut to the clipboard we |
44 // expect one call each to GroupedBookmarkChangesBeginning/Ended. | 44 // expect one call each to GroupedBookmarkChangesBeginning/Ended. |
45 void ExpectGroupedChangeCount(int expected_beginning_count, | 45 void ExpectGroupedChangeCount(int expected_beginning_count, |
46 int expected_ended_count) { | 46 int expected_ended_count) { |
47 // The undo framework is not used under Android. Thus the group change | 47 // The undo framework is not used under Android. Thus the group change |
48 // events will not be fired and so should not be tested for Android. | 48 // events will not be fired and so should not be tested for Android. |
49 #if !defined(OS_ANDROID) | 49 #if !defined(OS_ANDROID) |
50 EXPECT_EQ(grouped_changes_beginning_count_, expected_beginning_count); | 50 EXPECT_EQ(grouped_changes_beginning_count_, expected_beginning_count); |
51 EXPECT_EQ(grouped_changes_ended_count_, expected_ended_count); | 51 EXPECT_EQ(grouped_changes_ended_count_, expected_ended_count); |
52 #endif | 52 #endif |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 // BaseBookmarkModelObserver: | 56 // BaseBookmarkModelObserver: |
57 virtual void BookmarkModelChanged() OVERRIDE {} | 57 virtual void BookmarkModelChanged() override {} |
58 | 58 |
59 virtual void GroupedBookmarkChangesBeginning(BookmarkModel* model) OVERRIDE { | 59 virtual void GroupedBookmarkChangesBeginning(BookmarkModel* model) override { |
60 ++grouped_changes_beginning_count_; | 60 ++grouped_changes_beginning_count_; |
61 } | 61 } |
62 | 62 |
63 virtual void GroupedBookmarkChangesEnded(BookmarkModel* model) OVERRIDE { | 63 virtual void GroupedBookmarkChangesEnded(BookmarkModel* model) override { |
64 ++grouped_changes_ended_count_; | 64 ++grouped_changes_ended_count_; |
65 } | 65 } |
66 | 66 |
67 int grouped_changes_beginning_count_; | 67 int grouped_changes_beginning_count_; |
68 int grouped_changes_ended_count_; | 68 int grouped_changes_ended_count_; |
69 | 69 |
70 // Clipboard requires a message loop. | 70 // Clipboard requires a message loop. |
71 base::MessageLoopForUI loop_; | 71 base::MessageLoopForUI loop_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(BookmarkUtilsTest); | 73 DISALLOW_COPY_AND_ASSIGN(BookmarkUtilsTest); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 model->GetNodesByURL(url, &nodes); | 517 model->GetNodesByURL(url, &nodes); |
518 ASSERT_EQ(1u, nodes.size()); | 518 ASSERT_EQ(1u, nodes.size()); |
519 EXPECT_TRUE(model->bookmark_bar_node()->empty()); | 519 EXPECT_TRUE(model->bookmark_bar_node()->empty()); |
520 EXPECT_TRUE(model->other_node()->empty()); | 520 EXPECT_TRUE(model->other_node()->empty()); |
521 EXPECT_TRUE(model->mobile_node()->empty()); | 521 EXPECT_TRUE(model->mobile_node()->empty()); |
522 EXPECT_EQ(1, extra_node->child_count()); | 522 EXPECT_EQ(1, extra_node->child_count()); |
523 } | 523 } |
524 | 524 |
525 } // namespace | 525 } // namespace |
526 } // namespace bookmarks | 526 } // namespace bookmarks |
OLD | NEW |