| 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 <string> | 5 #include <string> |
| 6 #include <utility> | 6 #include <utility> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 namespace { | 81 namespace { |
| 82 | 82 |
| 83 const char kTestProfileName[] = "test-profile"; | 83 const char kTestProfileName[] = "test-profile"; |
| 84 | 84 |
| 85 // Visits with this timestamp are treated as expired. | 85 // Visits with this timestamp are treated as expired. |
| 86 static const int EXPIRED_VISIT = -1; | 86 static const int EXPIRED_VISIT = -1; |
| 87 | 87 |
| 88 class HistoryBackendMock : public HistoryBackend { | 88 class HistoryBackendMock : public HistoryBackend { |
| 89 public: | 89 public: |
| 90 HistoryBackendMock() : HistoryBackend(base::FilePath(), NULL, NULL) {} | 90 HistoryBackendMock() : HistoryBackend(base::FilePath(), NULL, NULL) {} |
| 91 virtual bool IsExpiredVisitTime(const base::Time& time) OVERRIDE { | 91 virtual bool IsExpiredVisitTime(const base::Time& time) override { |
| 92 return time.ToInternalValue() == EXPIRED_VISIT; | 92 return time.ToInternalValue() == EXPIRED_VISIT; |
| 93 } | 93 } |
| 94 MOCK_METHOD1(GetAllTypedURLs, bool(history::URLRows* entries)); | 94 MOCK_METHOD1(GetAllTypedURLs, bool(history::URLRows* entries)); |
| 95 MOCK_METHOD3(GetMostRecentVisitsForURL, bool(history::URLID id, | 95 MOCK_METHOD3(GetMostRecentVisitsForURL, bool(history::URLID id, |
| 96 int max_visits, | 96 int max_visits, |
| 97 history::VisitVector* visits)); | 97 history::VisitVector* visits)); |
| 98 MOCK_METHOD2(UpdateURL, bool(history::URLID id, const history::URLRow& url)); | 98 MOCK_METHOD2(UpdateURL, bool(history::URLID id, const history::URLRow& url)); |
| 99 MOCK_METHOD3(AddVisits, bool(const GURL& url, | 99 MOCK_METHOD3(AddVisits, bool(const GURL& url, |
| 100 const std::vector<history::VisitInfo>& visits, | 100 const std::vector<history::VisitInfo>& visits, |
| 101 history::VisitSource visit_source)); | 101 history::VisitSource visit_source)); |
| 102 MOCK_METHOD1(RemoveVisits, bool(const history::VisitVector& visits)); | 102 MOCK_METHOD1(RemoveVisits, bool(const history::VisitVector& visits)); |
| 103 MOCK_METHOD2(GetURL, bool(const GURL& url_id, history::URLRow* url_row)); | 103 MOCK_METHOD2(GetURL, bool(const GURL& url_id, history::URLRow* url_row)); |
| 104 MOCK_METHOD2(SetPageTitle, void(const GURL& url, | 104 MOCK_METHOD2(SetPageTitle, void(const GURL& url, |
| 105 const base::string16& title)); | 105 const base::string16& title)); |
| 106 MOCK_METHOD1(DeleteURL, void(const GURL& url)); | 106 MOCK_METHOD1(DeleteURL, void(const GURL& url)); |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 virtual ~HistoryBackendMock() {} | 109 virtual ~HistoryBackendMock() {} |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 class HistoryServiceMock : public HistoryService { | 112 class HistoryServiceMock : public HistoryService { |
| 113 public: | 113 public: |
| 114 HistoryServiceMock(history::HistoryClient* client, Profile* profile) | 114 HistoryServiceMock(history::HistoryClient* client, Profile* profile) |
| 115 : HistoryService(client, profile), backend_(NULL) {} | 115 : HistoryService(client, profile), backend_(NULL) {} |
| 116 | 116 |
| 117 virtual void ScheduleDBTask(scoped_ptr<history::HistoryDBTask> task, | 117 virtual void ScheduleDBTask(scoped_ptr<history::HistoryDBTask> task, |
| 118 base::CancelableTaskTracker* tracker) OVERRIDE { | 118 base::CancelableTaskTracker* tracker) override { |
| 119 history::HistoryDBTask* task_raw = task.get(); | 119 history::HistoryDBTask* task_raw = task.get(); |
| 120 task_runner_->PostTaskAndReply( | 120 task_runner_->PostTaskAndReply( |
| 121 FROM_HERE, | 121 FROM_HERE, |
| 122 base::Bind(&HistoryServiceMock::RunTaskOnDBThread, | 122 base::Bind(&HistoryServiceMock::RunTaskOnDBThread, |
| 123 base::Unretained(this), task_raw), | 123 base::Unretained(this), task_raw), |
| 124 base::Bind(&base::DeletePointer<history::HistoryDBTask>, | 124 base::Bind(&base::DeletePointer<history::HistoryDBTask>, |
| 125 task.release())); | 125 task.release())); |
| 126 } | 126 } |
| 127 | 127 |
| 128 MOCK_METHOD0(Shutdown, void()); | 128 MOCK_METHOD0(Shutdown, void()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 public: | 167 public: |
| 168 TestTypedUrlModelAssociator( | 168 TestTypedUrlModelAssociator( |
| 169 ProfileSyncService* sync_service, | 169 ProfileSyncService* sync_service, |
| 170 history::HistoryBackend* history_backend, | 170 history::HistoryBackend* history_backend, |
| 171 sync_driver::DataTypeErrorHandler* error_handler) : | 171 sync_driver::DataTypeErrorHandler* error_handler) : |
| 172 TypedUrlModelAssociator(sync_service, history_backend, error_handler) {} | 172 TypedUrlModelAssociator(sync_service, history_backend, error_handler) {} |
| 173 | 173 |
| 174 protected: | 174 protected: |
| 175 // Don't clear error stats - that way we can verify their values in our | 175 // Don't clear error stats - that way we can verify their values in our |
| 176 // tests. | 176 // tests. |
| 177 virtual void ClearErrorStats() OVERRIDE {} | 177 virtual void ClearErrorStats() override {} |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 ACTION_P2(ShutdownHistoryService, thread, service) { | 180 ACTION_P2(ShutdownHistoryService, thread, service) { |
| 181 service->ShutdownBaseService(); | 181 service->ShutdownBaseService(); |
| 182 delete thread; | 182 delete thread; |
| 183 } | 183 } |
| 184 | 184 |
| 185 ACTION_P6(MakeTypedUrlSyncComponents, | 185 ACTION_P6(MakeTypedUrlSyncComponents, |
| 186 profile, | 186 profile, |
| 187 service, | 187 service, |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 notifier->Notify(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, | 1138 notifier->Notify(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
| 1139 content::Source<Profile>(profile_), | 1139 content::Source<Profile>(profile_), |
| 1140 content::Details<history::URLsModifiedDetails>(&details)); | 1140 content::Details<history::URLsModifiedDetails>(&details)); |
| 1141 | 1141 |
| 1142 history::URLRows new_sync_entries; | 1142 history::URLRows new_sync_entries; |
| 1143 GetTypedUrlsFromSyncDB(&new_sync_entries); | 1143 GetTypedUrlsFromSyncDB(&new_sync_entries); |
| 1144 | 1144 |
| 1145 // The change should be ignored. | 1145 // The change should be ignored. |
| 1146 ASSERT_EQ(0U, new_sync_entries.size()); | 1146 ASSERT_EQ(0U, new_sync_entries.size()); |
| 1147 } | 1147 } |
| OLD | NEW |