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 // History unit tests come in two flavors: | 5 // History unit tests come in two flavors: |
6 // | 6 // |
7 // 1. The more complicated style is that the unit test creates a full history | 7 // 1. The more complicated style is that the unit test creates a full history |
8 // service. This spawns a background thread for the history backend, and | 8 // service. This spawns a background thread for the history backend, and |
9 // all communication is asynchronous. This is useful for testing more | 9 // all communication is asynchronous. This is useful for testing more |
10 // complicated things or end-to-end behavior. | 10 // complicated things or end-to-end behavior. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 HistoryBackendDBTest* history_test_; | 99 HistoryBackendDBTest* history_test_; |
100 }; | 100 }; |
101 | 101 |
102 // This must be outside the anonymous namespace for the friend statement in | 102 // This must be outside the anonymous namespace for the friend statement in |
103 // HistoryBackend to work. | 103 // HistoryBackend to work. |
104 class HistoryBackendDBTest : public HistoryUnitTestBase { | 104 class HistoryBackendDBTest : public HistoryUnitTestBase { |
105 public: | 105 public: |
106 HistoryBackendDBTest() : db_(NULL) { | 106 HistoryBackendDBTest() : db_(NULL) { |
107 } | 107 } |
108 | 108 |
109 ~HistoryBackendDBTest() { | 109 virtual ~HistoryBackendDBTest() { |
110 } | 110 } |
111 | 111 |
112 protected: | 112 protected: |
113 friend class BackendDelegate; | 113 friend class BackendDelegate; |
114 | 114 |
115 // Creates the HistoryBackend and HistoryDatabase on the current thread, | 115 // Creates the HistoryBackend and HistoryDatabase on the current thread, |
116 // assigning the values to backend_ and db_. | 116 // assigning the values to backend_ and db_. |
117 void CreateBackendAndDatabase() { | 117 void CreateBackendAndDatabase() { |
118 backend_ = new HistoryBackend(history_dir_, 0, new BackendDelegate(this), | 118 backend_ = new HistoryBackend(history_dir_, 0, new BackendDelegate(this), |
119 NULL); | 119 NULL); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 } | 557 } |
558 | 558 |
559 class HistoryTest : public testing::Test { | 559 class HistoryTest : public testing::Test { |
560 public: | 560 public: |
561 HistoryTest() | 561 HistoryTest() |
562 : got_thumbnail_callback_(false), | 562 : got_thumbnail_callback_(false), |
563 redirect_query_success_(false), | 563 redirect_query_success_(false), |
564 query_url_success_(false) { | 564 query_url_success_(false) { |
565 } | 565 } |
566 | 566 |
567 ~HistoryTest() { | 567 virtual ~HistoryTest() { |
568 } | 568 } |
569 | 569 |
570 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, | 570 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, |
571 std::vector<PageUsageData*>* data) { | 571 std::vector<PageUsageData*>* data) { |
572 page_usage_data_.swap(*data); | 572 page_usage_data_.swap(*data); |
573 MessageLoop::current()->Quit(); | 573 MessageLoop::current()->Quit(); |
574 } | 574 } |
575 | 575 |
576 void OnDeleteURLsDone(CancelableRequestProvider::Handle handle) { | 576 void OnDeleteURLsDone(CancelableRequestProvider::Handle handle) { |
577 MessageLoop::current()->Quit(); | 577 MessageLoop::current()->Quit(); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 // invoke_count is increment. When invoked kWantInvokeCount times, true is | 1182 // invoke_count is increment. When invoked kWantInvokeCount times, true is |
1183 // returned from RunOnDBThread which should stop RunOnDBThread from being | 1183 // returned from RunOnDBThread which should stop RunOnDBThread from being |
1184 // invoked again. When DoneRunOnMainThread is invoked, done_invoked is set to | 1184 // invoked again. When DoneRunOnMainThread is invoked, done_invoked is set to |
1185 // true. | 1185 // true. |
1186 class HistoryDBTaskImpl : public HistoryDBTask { | 1186 class HistoryDBTaskImpl : public HistoryDBTask { |
1187 public: | 1187 public: |
1188 static const int kWantInvokeCount; | 1188 static const int kWantInvokeCount; |
1189 | 1189 |
1190 HistoryDBTaskImpl() : invoke_count(0), done_invoked(false) {} | 1190 HistoryDBTaskImpl() : invoke_count(0), done_invoked(false) {} |
1191 | 1191 |
1192 virtual bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db) { | 1192 virtual bool RunOnDBThread(HistoryBackend* backend, |
| 1193 HistoryDatabase* db) OVERRIDE { |
1193 return (++invoke_count == kWantInvokeCount); | 1194 return (++invoke_count == kWantInvokeCount); |
1194 } | 1195 } |
1195 | 1196 |
1196 virtual void DoneRunOnMainThread() { | 1197 virtual void DoneRunOnMainThread() OVERRIDE { |
1197 done_invoked = true; | 1198 done_invoked = true; |
1198 MessageLoop::current()->Quit(); | 1199 MessageLoop::current()->Quit(); |
1199 } | 1200 } |
1200 | 1201 |
1201 int invoke_count; | 1202 int invoke_count; |
1202 bool done_invoked; | 1203 bool done_invoked; |
1203 | 1204 |
1204 private: | 1205 private: |
1205 virtual ~HistoryDBTaskImpl() {} | 1206 virtual ~HistoryDBTaskImpl() {} |
1206 | 1207 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 | 1440 |
1440 history_service_->StopSyncing(syncer::HISTORY_DELETE_DIRECTIVES); | 1441 history_service_->StopSyncing(syncer::HISTORY_DELETE_DIRECTIVES); |
1441 EXPECT_TRUE( | 1442 EXPECT_TRUE( |
1442 history_service_->ProcessLocalDeleteDirective(delete_directive).IsSet()); | 1443 history_service_->ProcessLocalDeleteDirective(delete_directive).IsSet()); |
1443 EXPECT_EQ(1u, change_processor.GetChanges().size()); | 1444 EXPECT_EQ(1u, change_processor.GetChanges().size()); |
1444 } | 1445 } |
1445 | 1446 |
1446 } // namespace | 1447 } // namespace |
1447 | 1448 |
1448 } // namespace history | 1449 } // namespace history |
OLD | NEW |