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

Side by Side Diff: chrome/browser/history/history_backend_unittest.cc

Issue 15275004: bookmarks: Get rid of the dependency on history_notifications.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add files back Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_details.h » ('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 (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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/string16.h" 18 #include "base/string16.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "chrome/browser/bookmarks/bookmark_model.h" 21 #include "chrome/browser/bookmarks/bookmark_model.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
22 #include "chrome/browser/bookmarks/bookmark_utils.h" 23 #include "chrome/browser/bookmarks/bookmark_utils.h"
23 #include "chrome/browser/favicon/imported_favicon_usage.h" 24 #include "chrome/browser/favicon/imported_favicon_usage.h"
24 #include "chrome/browser/history/history_backend.h" 25 #include "chrome/browser/history/history_backend.h"
25 #include "chrome/browser/history/history_notifications.h" 26 #include "chrome/browser/history/history_notifications.h"
27 #include "chrome/browser/history/history_service.h"
28 #include "chrome/browser/history/history_service_factory.h"
26 #include "chrome/browser/history/in_memory_database.h" 29 #include "chrome/browser/history/in_memory_database.h"
27 #include "chrome/browser/history/in_memory_history_backend.h" 30 #include "chrome/browser/history/in_memory_history_backend.h"
28 #include "chrome/browser/history/visit_filter.h" 31 #include "chrome/browser/history/visit_filter.h"
29 #include "chrome/common/chrome_constants.h" 32 #include "chrome/common/chrome_constants.h"
30 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/thumbnail_score.h" 35 #include "chrome/common/thumbnail_score.h"
36 #include "chrome/test/base/testing_profile.h"
37 #include "chrome/test/base/ui_test_utils.h"
33 #include "chrome/tools/profiles/thumbnail-inl.h" 38 #include "chrome/tools/profiles/thumbnail-inl.h"
34 #include "content/public/browser/notification_details.h" 39 #include "content/public/browser/notification_details.h"
35 #include "content/public/browser/notification_source.h" 40 #include "content/public/browser/notification_source.h"
41 #include "content/public/test/test_browser_thread.h"
36 #include "googleurl/src/gurl.h" 42 #include "googleurl/src/gurl.h"
37 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
38 #include "third_party/skia/include/core/SkBitmap.h" 44 #include "third_party/skia/include/core/SkBitmap.h"
39 #include "ui/gfx/codec/jpeg_codec.h" 45 #include "ui/gfx/codec/jpeg_codec.h"
40 #include "ui/gfx/image/image.h" 46 #include "ui/gfx/image/image.h"
41 47
42 using base::Time; 48 using base::Time;
43 using base::TimeDelta; 49 using base::TimeDelta;
44 50
45 // This file only tests functionality where it is most convenient to call the 51 // This file only tests functionality where it is most convenient to call the
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 AddRequest(request, this); 117 AddRequest(request, this);
112 return request->handle(); 118 return request->handle();
113 } 119 }
114 }; 120 };
115 121
116 class HistoryBackendTest : public testing::Test { 122 class HistoryBackendTest : public testing::Test {
117 public: 123 public:
118 HistoryBackendTest() 124 HistoryBackendTest()
119 : bookmark_model_(NULL), 125 : bookmark_model_(NULL),
120 loaded_(false), 126 loaded_(false),
121 num_broadcasted_notifications_(0) { 127 num_broadcasted_notifications_(0),
128 ui_thread_(content::BrowserThread::UI, &message_loop_) {
122 } 129 }
123 130
124 virtual ~HistoryBackendTest() { 131 virtual ~HistoryBackendTest() {
125 } 132 }
126 133
127 // Callback for QueryMostVisited. 134 // Callback for QueryMostVisited.
128 void OnQueryMostVisited(CancelableRequestProvider::Handle handle, 135 void OnQueryMostVisited(CancelableRequestProvider::Handle handle,
129 history::MostVisitedURLList data) { 136 history::MostVisitedURLList data) {
130 most_visited_list_.swap(data); 137 most_visited_list_.swap(data);
131 } 138 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 delete details; 410 delete details;
404 } 411 }
405 412
406 // The number of notifications which were broadcasted. 413 // The number of notifications which were broadcasted.
407 int num_broadcasted_notifications_; 414 int num_broadcasted_notifications_;
408 415
409 MessageLoop message_loop_; 416 MessageLoop message_loop_;
410 base::FilePath test_dir_; 417 base::FilePath test_dir_;
411 history::MostVisitedURLList most_visited_list_; 418 history::MostVisitedURLList most_visited_list_;
412 history::FilteredURLList filtered_list_; 419 history::FilteredURLList filtered_list_;
420 content::TestBrowserThread ui_thread_;
413 }; 421 };
414 422
415 void HistoryBackendTestDelegate::SetInMemoryBackend(int backend_id, 423 void HistoryBackendTestDelegate::SetInMemoryBackend(int backend_id,
416 InMemoryHistoryBackend* backend) { 424 InMemoryHistoryBackend* backend) {
417 test_->SetInMemoryBackend(backend_id, backend); 425 test_->SetInMemoryBackend(backend_id, backend);
418 } 426 }
419 427
420 void HistoryBackendTestDelegate::BroadcastNotifications( 428 void HistoryBackendTestDelegate::BroadcastNotifications(
421 int type, 429 int type,
422 HistoryDetails* details) { 430 HistoryDetails* details) {
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2774 ASSERT_EQ(2u, data.size()); 2782 ASSERT_EQ(2u, data.size());
2775 EXPECT_EQ(url2.spec(), data[0]->GetURL().spec()); 2783 EXPECT_EQ(url2.spec(), data[0]->GetURL().spec());
2776 EXPECT_EQ(url2_id, data[0]->GetID()); 2784 EXPECT_EQ(url2_id, data[0]->GetID());
2777 EXPECT_EQ(segment2_time_delta.InHours(), data[0]->duration().InHours()); 2785 EXPECT_EQ(segment2_time_delta.InHours(), data[0]->duration().InHours());
2778 2786
2779 EXPECT_EQ(url1.spec(), data[1]->GetURL().spec()); 2787 EXPECT_EQ(url1.spec(), data[1]->GetURL().spec());
2780 EXPECT_EQ(url1_id, data[1]->GetID()); 2788 EXPECT_EQ(url1_id, data[1]->GetID());
2781 EXPECT_EQ(segment1_time_delta.InHours(), data[1]->duration().InHours()); 2789 EXPECT_EQ(segment1_time_delta.InHours(), data[1]->duration().InHours());
2782 } 2790 }
2783 2791
2792 // Simple test that removes a bookmark. This test exercises the code paths in
2793 // History that block till bookmark bar model is loaded.
2794 TEST_F(HistoryBackendTest, RemoveNotification) {
2795 scoped_ptr<TestingProfile> profile(new TestingProfile());
2796
2797 profile->CreateHistoryService(false, false);
2798 profile->CreateBookmarkModel(true);
2799 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile.get());
2800 ui_test_utils::WaitForBookmarkModelToLoad(model);
2801
2802 // Add a URL.
2803 GURL url("http://www.google.com");
2804 bookmark_utils::AddIfNotBookmarked(model, url, base::string16());
2805
2806 HistoryService* service = HistoryServiceFactory::GetForProfile(
2807 profile.get(), Profile::EXPLICIT_ACCESS);
2808
2809 service->AddPage(
2810 url, base::Time::Now(), NULL, 1, GURL(), RedirectList(),
2811 content::PAGE_TRANSITION_TYPED, SOURCE_BROWSED, false);
2812
2813 // This won't actually delete the URL, rather it'll empty out the visits.
2814 // This triggers blocking on the BookmarkModel.
2815 service->DeleteURL(url);
2816 }
2817
2784 } // namespace history 2818 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698