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

Side by Side Diff: components/bookmarks/browser/bookmark_utils_unittest.cc

Issue 1892483005: SelectionOwner: add support for TIMESTAMP target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address feedback Created 4 years, 8 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
« no previous file with comments | « components/bookmarks/browser/BUILD.gn ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/bookmarks/browser/bookmark_utils.h" 5 #include "components/bookmarks/browser/bookmark_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "components/bookmarks/browser/base_bookmark_model_observer.h" 15 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
16 #include "components/bookmarks/browser/bookmark_model.h" 16 #include "components/bookmarks/browser/bookmark_model.h"
17 #include "components/bookmarks/browser/bookmark_node_data.h" 17 #include "components/bookmarks/browser/bookmark_node_data.h"
18 #include "components/bookmarks/test/test_bookmark_client.h" 18 #include "components/bookmarks/test/test_bookmark_client.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/base/clipboard/clipboard.h" 20 #include "ui/base/clipboard/clipboard.h"
21 #include "ui/base/clipboard/scoped_clipboard_writer.h" 21 #include "ui/base/clipboard/scoped_clipboard_writer.h"
22 22
23 #if defined(USE_X11)
24
25 #include <memory>
26
27 #include "ui/events/platform/x11/x11_event_source_glib.h" // nogncheck
28 #include "ui/gfx/x/x11_types.h" // nogncheck
29
30 #endif // defined(USE_X11)
31
23 using base::ASCIIToUTF16; 32 using base::ASCIIToUTF16;
24 using std::string; 33 using std::string;
25 34
26 namespace bookmarks { 35 namespace bookmarks {
27 namespace { 36 namespace {
28 37
29 class BookmarkUtilsTest : public testing::Test, 38 class BookmarkUtilsTest : public testing::Test,
30 public BaseBookmarkModelObserver { 39 public BaseBookmarkModelObserver {
31 public: 40 public:
32 BookmarkUtilsTest() 41 BookmarkUtilsTest()
33 : grouped_changes_beginning_count_(0), 42 : grouped_changes_beginning_count_(0), grouped_changes_ended_count_(0) {
34 grouped_changes_ended_count_(0) {} 43 #if defined(USE_X11)
44 event_source_.reset(new ui::X11EventSourceGlib(gfx::GetXDisplay()));
45 #endif // defined(USE_x11)
46 }
47
35 ~BookmarkUtilsTest() override {} 48 ~BookmarkUtilsTest() override {}
36 49
37 // Copy and paste is not yet supported on iOS. http://crbug.com/228147 50 // Copy and paste is not yet supported on iOS. http://crbug.com/228147
38 #if !defined(OS_IOS) 51 #if !defined(OS_IOS)
39 void TearDown() override { 52 void TearDown() override {
40 ui::Clipboard::DestroyClipboardForCurrentThread(); 53 ui::Clipboard::DestroyClipboardForCurrentThread();
41 } 54 }
42 #endif // !defined(OS_IOS) 55 #endif // !defined(OS_IOS)
43 56
44 // Certain user actions require multiple changes to the bookmark model, 57 // Certain user actions require multiple changes to the bookmark model,
(...skipping 21 matching lines...) Expand all
66 79
67 void GroupedBookmarkChangesEnded(BookmarkModel* model) override { 80 void GroupedBookmarkChangesEnded(BookmarkModel* model) override {
68 ++grouped_changes_ended_count_; 81 ++grouped_changes_ended_count_;
69 } 82 }
70 83
71 int grouped_changes_beginning_count_; 84 int grouped_changes_beginning_count_;
72 int grouped_changes_ended_count_; 85 int grouped_changes_ended_count_;
73 86
74 // Clipboard requires a message loop. 87 // Clipboard requires a message loop.
75 base::MessageLoopForUI loop_; 88 base::MessageLoopForUI loop_;
89 #if defined(USE_X11)
sadrul 2016/04/22 17:17:25 To be safe, guard all these with both USE_GLIB and
dcheng 2016/04/22 18:20:15 Done.
90 // On Linux, Clipboard also depends on an event source being present, to get
91 // the timestamp.
92 std::unique_ptr<ui::X11EventSourceGlib> event_source_;
93 #endif // defined(USE_X11)
76 94
77 DISALLOW_COPY_AND_ASSIGN(BookmarkUtilsTest); 95 DISALLOW_COPY_AND_ASSIGN(BookmarkUtilsTest);
78 }; 96 };
79 97
80 TEST_F(BookmarkUtilsTest, GetBookmarksMatchingPropertiesWordPhraseQuery) { 98 TEST_F(BookmarkUtilsTest, GetBookmarksMatchingPropertiesWordPhraseQuery) {
81 scoped_ptr<BookmarkModel> model(TestBookmarkClient::CreateModel()); 99 scoped_ptr<BookmarkModel> model(TestBookmarkClient::CreateModel());
82 const BookmarkNode* node1 = model->AddURL(model->other_node(), 100 const BookmarkNode* node1 = model->AddURL(model->other_node(),
83 0, 101 0,
84 ASCIIToUTF16("foo bar"), 102 ASCIIToUTF16("foo bar"),
85 GURL("http://www.google.com")); 103 GURL("http://www.google.com"));
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 model->GetNodesByURL(url, &nodes); 615 model->GetNodesByURL(url, &nodes);
598 ASSERT_EQ(1u, nodes.size()); 616 ASSERT_EQ(1u, nodes.size());
599 EXPECT_TRUE(model->bookmark_bar_node()->empty()); 617 EXPECT_TRUE(model->bookmark_bar_node()->empty());
600 EXPECT_TRUE(model->other_node()->empty()); 618 EXPECT_TRUE(model->other_node()->empty());
601 EXPECT_TRUE(model->mobile_node()->empty()); 619 EXPECT_TRUE(model->mobile_node()->empty());
602 EXPECT_EQ(1, extra_node->child_count()); 620 EXPECT_EQ(1, extra_node->child_count());
603 } 621 }
604 622
605 } // namespace 623 } // namespace
606 } // namespace bookmarks 624 } // namespace bookmarks
OLDNEW
« no previous file with comments | « components/bookmarks/browser/BUILD.gn ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698