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 #include <cstdio> | 5 #include <cstdio> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/time.h" |
15 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" | 16 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" |
16 #include "chrome/browser/visitedlink/visitedlink_master.h" | 17 #include "chrome/browser/visitedlink/visitedlink_master.h" |
17 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
18 #include "chrome/renderer/visitedlink_slave.h" | 19 #include "chrome/renderer/visitedlink_slave.h" |
19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
20 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
23 #include "content/public/test/mock_render_process_host.h" | 24 #include "content/public/test/mock_render_process_host.h" |
24 #include "content/public/test/test_browser_thread.h" | 25 #include "content/public/test/test_browser_thread.h" |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 375 } |
375 | 376 |
376 // Tests that if the database doesn't exist, it will be rebuilt from history. | 377 // Tests that if the database doesn't exist, it will be rebuilt from history. |
377 TEST_F(VisitedLinkTest, Rebuild) { | 378 TEST_F(VisitedLinkTest, Rebuild) { |
378 ASSERT_TRUE(InitHistory()); | 379 ASSERT_TRUE(InitHistory()); |
379 | 380 |
380 // Add half of our URLs to history. This needs to be done before we | 381 // Add half of our URLs to history. This needs to be done before we |
381 // initialize the visited link DB. | 382 // initialize the visited link DB. |
382 int history_count = g_test_count / 2; | 383 int history_count = g_test_count / 2; |
383 for (int i = 0; i < history_count; i++) | 384 for (int i = 0; i < history_count; i++) |
384 history_service_->AddPage(TestURL(i), history::SOURCE_BROWSED); | 385 history_service_->AddPage( |
| 386 TestURL(i), base::Time::Now(), history::SOURCE_BROWSED); |
385 | 387 |
386 // Initialize the visited link DB. Since the visited links file doesn't exist | 388 // Initialize the visited link DB. Since the visited links file doesn't exist |
387 // and we don't suppress history rebuilding, this will load from history. | 389 // and we don't suppress history rebuilding, this will load from history. |
388 ASSERT_TRUE(InitVisited(0, false)); | 390 ASSERT_TRUE(InitVisited(0, false)); |
389 | 391 |
390 // While the table is rebuilding, add the rest of the URLs to the visited | 392 // While the table is rebuilding, add the rest of the URLs to the visited |
391 // link system. This isn't guaranteed to happen during the rebuild, so we | 393 // link system. This isn't guaranteed to happen during the rebuild, so we |
392 // can't be 100% sure we're testing the right thing, but in practice is. | 394 // can't be 100% sure we're testing the right thing, but in practice is. |
393 // All the adds above will generally take some time queuing up on the | 395 // All the adds above will generally take some time queuing up on the |
394 // history thread, and it will take a while to catch up to actually | 396 // history thread, and it will take a while to catch up to actually |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 EXPECT_EQ(1, profile()->add_event_count()); | 722 EXPECT_EQ(1, profile()->add_event_count()); |
721 EXPECT_EQ(0, profile()->reset_event_count()); | 723 EXPECT_EQ(0, profile()->reset_event_count()); |
722 | 724 |
723 // Activate the tab. | 725 // Activate the tab. |
724 rvh_tester()->SimulateWasShown(); | 726 rvh_tester()->SimulateWasShown(); |
725 | 727 |
726 // We should have only one more reset event. | 728 // We should have only one more reset event. |
727 EXPECT_EQ(1, profile()->add_event_count()); | 729 EXPECT_EQ(1, profile()->add_event_count()); |
728 EXPECT_EQ(1, profile()->reset_event_count()); | 730 EXPECT_EQ(1, profile()->reset_event_count()); |
729 } | 731 } |
OLD | NEW |