OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_ |
6 #define CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_ | 6 #define CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_ |
7 | 7 |
8 #include "base/files/scoped_temp_dir.h" | |
9 #include "base/message_loop.h" | |
10 #include "chrome/browser/importer/profile_writer.h" | 8 #include "chrome/browser/importer/profile_writer.h" |
11 #include "content/public/test/test_browser_thread.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 namespace importer { | |
15 class ImporterProgressObserver; | |
16 } | |
17 | |
18 class TestingProfile; | |
19 | 9 |
20 const int kMaxPathSize = 5; | 10 const int kMaxPathSize = 5; |
21 | 11 |
22 struct BookmarkInfo { | 12 struct BookmarkInfo { |
23 const bool in_toolbar; | 13 const bool in_toolbar; |
24 const size_t path_size; | 14 const size_t path_size; |
25 const wchar_t* path[kMaxPathSize]; | 15 const wchar_t* path[kMaxPathSize]; |
26 const wchar_t* title; | 16 const wchar_t* title; |
27 const char* url; | 17 const char* url; |
28 }; | 18 }; |
29 | 19 |
30 // Returns true if the |entry| is equal to |expected|. | 20 // Generates an assertion error if |entry| is not equal to |expected|. Wrap this |
31 bool EqualBookmarkEntry(const ProfileWriter::BookmarkEntry& entry, | 21 // method in (ASSERT|EXPECT)_NO_FATAL_FAILURE to catch the error if one is |
32 const BookmarkInfo& expected); | 22 // generated. |
33 | 23 void TestEqualBookmarkEntry(const ProfileWriter::BookmarkEntry& entry, |
34 // Returns true if the |entry| is in the |list|. | 24 const BookmarkInfo& expected); |
35 bool FindBookmarkEntry(const ProfileWriter::BookmarkEntry& entry, | |
36 const BookmarkInfo* list, | |
37 int list_size); | |
38 | |
39 // Test fixture class providing a message loop, ui/file thread, | |
40 // and a scoped temporary directory. | |
41 class ImporterTest : public testing::Test { | |
42 public: | |
43 ImporterTest(); | |
44 virtual ~ImporterTest(); | |
45 | |
46 protected: | |
47 virtual void SetUp() OVERRIDE; | |
48 | |
49 base::ScopedTempDir temp_dir_; | |
50 scoped_ptr<TestingProfile> profile_; | |
51 | |
52 private: | |
53 MessageLoopForUI message_loop_; | |
54 content::TestBrowserThread ui_thread_; | |
55 content::TestBrowserThread file_thread_; | |
56 }; | |
57 | 25 |
58 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_ | 26 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_ |
OLD | NEW |