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_node_data.h" | 5 #include "components/bookmarks/browser/bookmark_node_data.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | |
12 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
13 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/test/scoped_task_environment.h" |
14 #include "components/bookmarks/browser/bookmark_model.h" | 14 #include "components/bookmarks/browser/bookmark_model.h" |
15 #include "components/bookmarks/test/bookmark_test_helpers.h" | 15 #include "components/bookmarks/test/bookmark_test_helpers.h" |
16 #include "components/bookmarks/test/test_bookmark_client.h" | 16 #include "components/bookmarks/test/test_bookmark_client.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "ui/base/clipboard/clipboard.h" | 18 #include "ui/base/clipboard/clipboard.h" |
19 #include "ui/base/dragdrop/os_exchange_data.h" | 19 #include "ui/base/dragdrop/os_exchange_data.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
22 using base::ASCIIToUTF16; | 22 using base::ASCIIToUTF16; |
23 | 23 |
24 namespace bookmarks { | 24 namespace bookmarks { |
25 | 25 |
26 class BookmarkNodeDataTest : public testing::Test { | 26 class BookmarkNodeDataTest : public testing::Test { |
27 public: | 27 public: |
28 BookmarkNodeDataTest() {} | 28 BookmarkNodeDataTest() |
| 29 : scoped_task_environment_( |
| 30 base::test::ScopedTaskEnvironment::MainThreadType::UI) {} |
29 | 31 |
30 void SetUp() override { | 32 void SetUp() override { |
31 model_ = TestBookmarkClient::CreateModel(); | 33 model_ = TestBookmarkClient::CreateModel(); |
32 test::WaitForBookmarkModelToLoad(model_.get()); | 34 test::WaitForBookmarkModelToLoad(model_.get()); |
33 bool success = profile_dir_.CreateUniqueTempDir(); | 35 bool success = profile_dir_.CreateUniqueTempDir(); |
34 ASSERT_TRUE(success); | 36 ASSERT_TRUE(success); |
35 } | 37 } |
36 | 38 |
37 void TearDown() override { | 39 void TearDown() override { |
38 model_.reset(); | 40 model_.reset(); |
39 bool success = profile_dir_.Delete(); | 41 bool success = profile_dir_.Delete(); |
40 ASSERT_TRUE(success); | 42 ASSERT_TRUE(success); |
41 ui::Clipboard::DestroyClipboardForCurrentThread(); | 43 ui::Clipboard::DestroyClipboardForCurrentThread(); |
42 } | 44 } |
43 | 45 |
44 const base::FilePath& GetProfilePath() const { | 46 const base::FilePath& GetProfilePath() const { |
45 return profile_dir_.GetPath(); | 47 return profile_dir_.GetPath(); |
46 } | 48 } |
47 | 49 |
48 BookmarkModel* model() { return model_.get(); } | 50 BookmarkModel* model() { return model_.get(); } |
49 | 51 |
50 protected: | 52 protected: |
51 ui::Clipboard& clipboard() { return *ui::Clipboard::GetForCurrentThread(); } | 53 ui::Clipboard& clipboard() { return *ui::Clipboard::GetForCurrentThread(); } |
52 | 54 |
53 private: | 55 private: |
54 base::ScopedTempDir profile_dir_; | 56 base::ScopedTempDir profile_dir_; |
55 std::unique_ptr<BookmarkModel> model_; | 57 std::unique_ptr<BookmarkModel> model_; |
56 base::MessageLoopForUI loop_; | 58 base::test::ScopedTaskEnvironment scoped_task_environment_; |
57 | 59 |
58 DISALLOW_COPY_AND_ASSIGN(BookmarkNodeDataTest); | 60 DISALLOW_COPY_AND_ASSIGN(BookmarkNodeDataTest); |
59 }; | 61 }; |
60 | 62 |
61 namespace { | 63 namespace { |
62 | 64 |
63 std::unique_ptr<ui::OSExchangeData::Provider> CloneProvider( | 65 std::unique_ptr<ui::OSExchangeData::Provider> CloneProvider( |
64 const ui::OSExchangeData& data) { | 66 const ui::OSExchangeData& data) { |
65 return data.provider().Clone(); | 67 return data.provider().Clone(); |
66 } | 68 } |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 ASSERT_EQ(1u, read_data.size()); | 399 ASSERT_EQ(1u, read_data.size()); |
398 | 400 |
399 // Verify that the read data contains the same meta info. | 401 // Verify that the read data contains the same meta info. |
400 BookmarkNode::MetaInfoMap meta_info_map = read_data.elements[0].meta_info_map; | 402 BookmarkNode::MetaInfoMap meta_info_map = read_data.elements[0].meta_info_map; |
401 EXPECT_EQ(2u, meta_info_map.size()); | 403 EXPECT_EQ(2u, meta_info_map.size()); |
402 EXPECT_EQ("somevalue", meta_info_map["somekey"]); | 404 EXPECT_EQ("somevalue", meta_info_map["somekey"]); |
403 EXPECT_EQ("someothervalue", meta_info_map["someotherkey"]); | 405 EXPECT_EQ("someothervalue", meta_info_map["someotherkey"]); |
404 } | 406 } |
405 | 407 |
406 } // namespace bookmarks | 408 } // namespace bookmarks |
OLD | NEW |