| 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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
| 5 #include <string> | 8 #include <string> |
| 6 #include <utility> | 9 #include <utility> |
| 7 #include <vector> | 10 #include <vector> |
| 8 | 11 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 13 |
| 11 #include "base/bind.h" | 14 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 16 #include "base/callback.h" |
| 14 #include "base/location.h" | 17 #include "base/location.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 293 } |
| 291 | 294 |
| 292 void GetTypedUrlsFromSyncDB(history::URLRows* urls) { | 295 void GetTypedUrlsFromSyncDB(history::URLRows* urls) { |
| 293 urls->clear(); | 296 urls->clear(); |
| 294 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 297 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 295 syncer::ReadNode typed_url_root(&trans); | 298 syncer::ReadNode typed_url_root(&trans); |
| 296 if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) != | 299 if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) != |
| 297 syncer::BaseNode::INIT_OK) | 300 syncer::BaseNode::INIT_OK) |
| 298 return; | 301 return; |
| 299 | 302 |
| 300 int64 child_id = typed_url_root.GetFirstChildId(); | 303 int64_t child_id = typed_url_root.GetFirstChildId(); |
| 301 while (child_id != syncer::kInvalidId) { | 304 while (child_id != syncer::kInvalidId) { |
| 302 syncer::ReadNode child_node(&trans); | 305 syncer::ReadNode child_node(&trans); |
| 303 if (child_node.InitByIdLookup(child_id) != syncer::BaseNode::INIT_OK) | 306 if (child_node.InitByIdLookup(child_id) != syncer::BaseNode::INIT_OK) |
| 304 return; | 307 return; |
| 305 | 308 |
| 306 const sync_pb::TypedUrlSpecifics& typed_url( | 309 const sync_pb::TypedUrlSpecifics& typed_url( |
| 307 child_node.GetTypedUrlSpecifics()); | 310 child_node.GetTypedUrlSpecifics()); |
| 308 history::URLRow new_url(GURL(typed_url.url())); | 311 history::URLRow new_url(GURL(typed_url.url())); |
| 309 | 312 |
| 310 new_url.set_title(base::UTF8ToUTF16(typed_url.title())); | 313 new_url.set_title(base::UTF8ToUTF16(typed_url.title())); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // and they are left unchanged by HistoryBackendMock). | 374 // and they are left unchanged by HistoryBackendMock). |
| 372 return (lhs.url().spec().compare(rhs.url().spec()) == 0) && | 375 return (lhs.url().spec().compare(rhs.url().spec()) == 0) && |
| 373 (lhs.title().compare(rhs.title()) == 0) && | 376 (lhs.title().compare(rhs.title()) == 0) && |
| 374 (lhs.last_visit() == rhs.last_visit()) && | 377 (lhs.last_visit() == rhs.last_visit()) && |
| 375 (lhs.hidden() == rhs.hidden()); | 378 (lhs.hidden() == rhs.hidden()); |
| 376 } | 379 } |
| 377 | 380 |
| 378 static history::URLRow MakeTypedUrlEntry(const char* url, | 381 static history::URLRow MakeTypedUrlEntry(const char* url, |
| 379 const char* title, | 382 const char* title, |
| 380 int typed_count, | 383 int typed_count, |
| 381 int64 last_visit, | 384 int64_t last_visit, |
| 382 bool hidden, | 385 bool hidden, |
| 383 history::VisitVector* visits) { | 386 history::VisitVector* visits) { |
| 384 // Give each URL a unique ID, to mimic the behavior of the real database. | 387 // Give each URL a unique ID, to mimic the behavior of the real database. |
| 385 static int unique_url_id = 0; | 388 static int unique_url_id = 0; |
| 386 GURL gurl(url); | 389 GURL gurl(url); |
| 387 URLRow history_url(gurl, ++unique_url_id); | 390 URLRow history_url(gurl, ++unique_url_id); |
| 388 history_url.set_title(base::UTF8ToUTF16(title)); | 391 history_url.set_title(base::UTF8ToUTF16(title)); |
| 389 history_url.set_typed_count(typed_count); | 392 history_url.set_typed_count(typed_count); |
| 390 history_url.set_last_visit( | 393 history_url.set_last_visit( |
| 391 base::Time::FromInternalValue(last_visit)); | 394 base::Time::FromInternalValue(last_visit)); |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 history::URLRows changed_urls; | 1116 history::URLRows changed_urls; |
| 1114 changed_urls.push_back(updated_url_entry); | 1117 changed_urls.push_back(updated_url_entry); |
| 1115 SendNotificationURLsModified(changed_urls); | 1118 SendNotificationURLsModified(changed_urls); |
| 1116 | 1119 |
| 1117 history::URLRows new_sync_entries; | 1120 history::URLRows new_sync_entries; |
| 1118 GetTypedUrlsFromSyncDB(&new_sync_entries); | 1121 GetTypedUrlsFromSyncDB(&new_sync_entries); |
| 1119 | 1122 |
| 1120 // The change should be ignored. | 1123 // The change should be ignored. |
| 1121 ASSERT_EQ(0U, new_sync_entries.size()); | 1124 ASSERT_EQ(0U, new_sync_entries.size()); |
| 1122 } | 1125 } |
| OLD | NEW |