OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | |
8 #include "base/file_util.h" | 7 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
10 #include "base/path_service.h" | 9 #include "base/path_service.h" |
11 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
12 #include "base/string_util.h" | 11 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 13 #include "base/values.h" |
15 #include "chrome/browser/history/history_backend.h" | 14 #include "chrome/browser/history/history_backend.h" |
16 #include "chrome/browser/history/history_database.h" | 15 #include "chrome/browser/history/history_database.h" |
17 #include "chrome/browser/history/history_marshaling.h" | 16 #include "chrome/browser/history/history_marshaling.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 return false; | 126 return false; |
128 return !memcmp(t1->front(), t2->front(), t1->size()); | 127 return !memcmp(t1->front(), t2->front(), t1->size()); |
129 } | 128 } |
130 | 129 |
131 } // namespace | 130 } // namespace |
132 | 131 |
133 class TopSitesTest : public HistoryUnitTestBase { | 132 class TopSitesTest : public HistoryUnitTestBase { |
134 public: | 133 public: |
135 TopSitesTest() | 134 TopSitesTest() |
136 : ui_thread_(BrowserThread::UI, &message_loop_), | 135 : ui_thread_(BrowserThread::UI, &message_loop_), |
137 db_thread_(BrowserThread::DB, &message_loop_), | 136 db_thread_(BrowserThread::DB, &message_loop_) { |
138 original_command_line_(*CommandLine::ForCurrentProcess()) { | |
139 } | 137 } |
140 | 138 |
141 virtual void SetUp() { | 139 virtual void SetUp() { |
142 profile_.reset(new TestingProfile); | 140 profile_.reset(new TestingProfile); |
143 if (CreateHistoryAndTopSites()) { | 141 if (CreateHistoryAndTopSites()) { |
144 profile_->CreateHistoryService(false, false); | 142 profile_->CreateHistoryService(false, false); |
145 profile_->CreateTopSites(); | 143 profile_->CreateTopSites(); |
146 profile_->BlockUntilTopSitesLoaded(); | 144 profile_->BlockUntilTopSitesLoaded(); |
147 } | 145 } |
148 } | 146 } |
149 | 147 |
150 virtual void TearDown() { | 148 virtual void TearDown() { |
151 profile_.reset(); | 149 profile_.reset(); |
152 *CommandLine::ForCurrentProcess() = original_command_line_; | |
153 } | 150 } |
154 | 151 |
155 // Returns true if history and top sites should be created in SetUp. | 152 // Returns true if history and top sites should be created in SetUp. |
156 virtual bool CreateHistoryAndTopSites() { | 153 virtual bool CreateHistoryAndTopSites() { |
157 return true; | 154 return true; |
158 } | 155 } |
159 | 156 |
160 // Gets the thumbnail for |url| from TopSites. | 157 // Gets the thumbnail for |url| from TopSites. |
161 SkBitmap GetThumbnail(const GURL& url) { | 158 SkBitmap GetThumbnail(const GURL& url) { |
162 scoped_refptr<RefCountedMemory> data; | 159 scoped_refptr<RefCountedMemory> data; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 bool AddPrepopulatedPages(MostVisitedURLList* urls) { | 313 bool AddPrepopulatedPages(MostVisitedURLList* urls) { |
317 return TopSites::AddPrepopulatedPages(urls); | 314 return TopSites::AddPrepopulatedPages(urls); |
318 } | 315 } |
319 | 316 |
320 private: | 317 private: |
321 MessageLoopForUI message_loop_; | 318 MessageLoopForUI message_loop_; |
322 content::TestBrowserThread ui_thread_; | 319 content::TestBrowserThread ui_thread_; |
323 content::TestBrowserThread db_thread_; | 320 content::TestBrowserThread db_thread_; |
324 scoped_ptr<TestingProfile> profile_; | 321 scoped_ptr<TestingProfile> profile_; |
325 CancelableRequestConsumer consumer_; | 322 CancelableRequestConsumer consumer_; |
326 CommandLine original_command_line_; | |
327 | 323 |
328 DISALLOW_COPY_AND_ASSIGN(TopSitesTest); | 324 DISALLOW_COPY_AND_ASSIGN(TopSitesTest); |
329 }; // Class TopSitesTest | 325 }; // Class TopSitesTest |
330 | 326 |
331 class TopSitesMigrationTest : public TopSitesTest { | 327 class TopSitesMigrationTest : public TopSitesTest { |
332 public: | 328 public: |
333 TopSitesMigrationTest() {} | 329 TopSitesMigrationTest() {} |
334 | 330 |
335 virtual void SetUp() { | 331 virtual void SetUp() { |
336 TopSitesTest::SetUp(); | 332 TopSitesTest::SetUp(); |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 ui_test_utils::WindowedNotificationObserver observer( | 1385 ui_test_utils::WindowedNotificationObserver observer( |
1390 chrome::NOTIFICATION_TOP_SITES_LOADED, | 1386 chrome::NOTIFICATION_TOP_SITES_LOADED, |
1391 content::Source<Profile>(profile())); | 1387 content::Source<Profile>(profile())); |
1392 profile()->CreateTopSites(); | 1388 profile()->CreateTopSites(); |
1393 profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)->UnloadBackend(); | 1389 profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)->UnloadBackend(); |
1394 profile()->BlockUntilHistoryProcessesPendingRequests(); | 1390 profile()->BlockUntilHistoryProcessesPendingRequests(); |
1395 observer.Wait(); | 1391 observer.Wait(); |
1396 } | 1392 } |
1397 | 1393 |
1398 } // namespace history | 1394 } // namespace history |
OLD | NEW |