| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Delegate class for when we create a backend without a HistoryService. | 86 // Delegate class for when we create a backend without a HistoryService. |
| 87 // | 87 // |
| 88 // This must be outside the anonymous namespace for the friend statement in | 88 // This must be outside the anonymous namespace for the friend statement in |
| 89 // HistoryBackendDBTest to work. | 89 // HistoryBackendDBTest to work. |
| 90 class BackendDelegate : public HistoryBackend::Delegate { | 90 class BackendDelegate : public HistoryBackend::Delegate { |
| 91 public: | 91 public: |
| 92 explicit BackendDelegate(HistoryBackendDBTest* history_test) | 92 explicit BackendDelegate(HistoryBackendDBTest* history_test) |
| 93 : history_test_(history_test) { | 93 : history_test_(history_test) { |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void NotifyProfileError(sql::InitStatus init_status) OVERRIDE {} | 96 virtual void NotifyProfileError(sql::InitStatus init_status) override {} |
| 97 virtual void SetInMemoryBackend( | 97 virtual void SetInMemoryBackend( |
| 98 scoped_ptr<InMemoryHistoryBackend> backend) OVERRIDE; | 98 scoped_ptr<InMemoryHistoryBackend> backend) override; |
| 99 virtual void NotifyFaviconChanged(const std::set<GURL>& url) OVERRIDE {} | 99 virtual void NotifyFaviconChanged(const std::set<GURL>& url) override {} |
| 100 virtual void BroadcastNotifications( | 100 virtual void BroadcastNotifications( |
| 101 int type, | 101 int type, |
| 102 scoped_ptr<HistoryDetails> details) OVERRIDE; | 102 scoped_ptr<HistoryDetails> details) override; |
| 103 virtual void DBLoaded() OVERRIDE {} | 103 virtual void DBLoaded() override {} |
| 104 virtual void NotifyVisitDBObserversOnAddVisit( | 104 virtual void NotifyVisitDBObserversOnAddVisit( |
| 105 const BriefVisitInfo& info) OVERRIDE {} | 105 const BriefVisitInfo& info) override {} |
| 106 private: | 106 private: |
| 107 HistoryBackendDBTest* history_test_; | 107 HistoryBackendDBTest* history_test_; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 // This must be outside the anonymous namespace for the friend statement in | 110 // This must be outside the anonymous namespace for the friend statement in |
| 111 // HistoryBackend to work. | 111 // HistoryBackend to work. |
| 112 class HistoryBackendDBTest : public HistoryUnitTestBase { | 112 class HistoryBackendDBTest : public HistoryUnitTestBase { |
| 113 public: | 113 public: |
| 114 HistoryBackendDBTest() : db_(NULL) { | 114 HistoryBackendDBTest() : db_(NULL) { |
| 115 } | 115 } |
| (...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 // invoked again. When DoneRunOnMainThread is invoked, done_invoked is set to | 1497 // invoked again. When DoneRunOnMainThread is invoked, done_invoked is set to |
| 1498 // true. | 1498 // true. |
| 1499 class HistoryDBTaskImpl : public HistoryDBTask { | 1499 class HistoryDBTaskImpl : public HistoryDBTask { |
| 1500 public: | 1500 public: |
| 1501 static const int kWantInvokeCount; | 1501 static const int kWantInvokeCount; |
| 1502 | 1502 |
| 1503 HistoryDBTaskImpl(int* invoke_count, bool* done_invoked) | 1503 HistoryDBTaskImpl(int* invoke_count, bool* done_invoked) |
| 1504 : invoke_count_(invoke_count), done_invoked_(done_invoked) {} | 1504 : invoke_count_(invoke_count), done_invoked_(done_invoked) {} |
| 1505 | 1505 |
| 1506 virtual bool RunOnDBThread(HistoryBackend* backend, | 1506 virtual bool RunOnDBThread(HistoryBackend* backend, |
| 1507 HistoryDatabase* db) OVERRIDE { | 1507 HistoryDatabase* db) override { |
| 1508 return (++*invoke_count_ == kWantInvokeCount); | 1508 return (++*invoke_count_ == kWantInvokeCount); |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 virtual void DoneRunOnMainThread() OVERRIDE { | 1511 virtual void DoneRunOnMainThread() override { |
| 1512 *done_invoked_ = true; | 1512 *done_invoked_ = true; |
| 1513 base::MessageLoop::current()->Quit(); | 1513 base::MessageLoop::current()->Quit(); |
| 1514 } | 1514 } |
| 1515 | 1515 |
| 1516 int* invoke_count_; | 1516 int* invoke_count_; |
| 1517 bool* done_invoked_; | 1517 bool* done_invoked_; |
| 1518 | 1518 |
| 1519 private: | 1519 private: |
| 1520 virtual ~HistoryDBTaskImpl() {} | 1520 virtual ~HistoryDBTaskImpl() {} |
| 1521 | 1521 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 std::vector<PageUsageData*> results; | 1866 std::vector<PageUsageData*> results; |
| 1867 db_->QuerySegmentUsage(segment_time, 10, &results); | 1867 db_->QuerySegmentUsage(segment_time, 10, &results); |
| 1868 ASSERT_EQ(1u, results.size()); | 1868 ASSERT_EQ(1u, results.size()); |
| 1869 EXPECT_EQ(url, results[0]->GetURL()); | 1869 EXPECT_EQ(url, results[0]->GetURL()); |
| 1870 EXPECT_EQ(segment_id, results[0]->GetID()); | 1870 EXPECT_EQ(segment_id, results[0]->GetID()); |
| 1871 EXPECT_EQ(title, results[0]->GetTitle()); | 1871 EXPECT_EQ(title, results[0]->GetTitle()); |
| 1872 STLDeleteElements(&results); | 1872 STLDeleteElements(&results); |
| 1873 } | 1873 } |
| 1874 | 1874 |
| 1875 } // namespace history | 1875 } // namespace history |
| OLD | NEW |