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

Side by Side Diff: chrome/browser/history/android/android_provider_backend_unittest.cc

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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
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 "chrome/browser/history/android/android_provider_backend.h" 5 #include "chrome/browser/history/android/android_provider_backend.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 DISALLOW_COPY_AND_ASSIGN(AndroidProviderBackendTest); 218 DISALLOW_COPY_AND_ASSIGN(AndroidProviderBackendTest);
219 }; 219 };
220 220
221 TEST_F(AndroidProviderBackendTest, UpdateTables) { 221 TEST_F(AndroidProviderBackendTest, UpdateTables) {
222 GURL url1("http://www.cnn.com"); 222 GURL url1("http://www.cnn.com");
223 URLID url_id1 = 0; 223 URLID url_id1 = 0;
224 std::vector<VisitInfo> visits1; 224 std::vector<VisitInfo> visits1;
225 Time last_visited1 = Time::Now() - TimeDelta::FromDays(1); 225 Time last_visited1 = Time::Now() - TimeDelta::FromDays(1);
226 Time created1 = last_visited1 - TimeDelta::FromDays(20); 226 Time created1 = last_visited1 - TimeDelta::FromDays(20);
227 visits1.push_back(VisitInfo(created1, content::PAGE_TRANSITION_LINK)); 227 visits1.push_back(VisitInfo(created1, ui::PAGE_TRANSITION_LINK));
228 visits1.push_back(VisitInfo(last_visited1 - TimeDelta::FromDays(1), 228 visits1.push_back(VisitInfo(last_visited1 - TimeDelta::FromDays(1),
229 content::PAGE_TRANSITION_LINK)); 229 ui::PAGE_TRANSITION_LINK));
230 visits1.push_back(VisitInfo(last_visited1, content::PAGE_TRANSITION_LINK)); 230 visits1.push_back(VisitInfo(last_visited1, ui::PAGE_TRANSITION_LINK));
231 231
232 GURL url2("http://www.example.com"); 232 GURL url2("http://www.example.com");
233 URLID url_id2 = 0; 233 URLID url_id2 = 0;
234 std::vector<VisitInfo> visits2; 234 std::vector<VisitInfo> visits2;
235 Time last_visited2 = Time::Now(); 235 Time last_visited2 = Time::Now();
236 Time created2 = last_visited2 - TimeDelta::FromDays(10); 236 Time created2 = last_visited2 - TimeDelta::FromDays(10);
237 visits2.push_back(VisitInfo(created2, content::PAGE_TRANSITION_LINK)); 237 visits2.push_back(VisitInfo(created2, ui::PAGE_TRANSITION_LINK));
238 visits2.push_back(VisitInfo(last_visited2 - TimeDelta::FromDays(5), 238 visits2.push_back(VisitInfo(last_visited2 - TimeDelta::FromDays(5),
239 content::PAGE_TRANSITION_LINK)); 239 ui::PAGE_TRANSITION_LINK));
240 visits2.push_back(VisitInfo(last_visited2, content::PAGE_TRANSITION_LINK)); 240 visits2.push_back(VisitInfo(last_visited2, ui::PAGE_TRANSITION_LINK));
241 241
242 // Add a bookmark which is not in the history. 242 // Add a bookmark which is not in the history.
243 GURL url3("http://www.bookmark.com"); 243 GURL url3("http://www.bookmark.com");
244 base::string16 title3(UTF8ToUTF16("bookmark")); 244 base::string16 title3(UTF8ToUTF16("bookmark"));
245 ASSERT_TRUE(bookmark_model_->AddURL(bookmark_model_->bookmark_bar_node(), 0, 245 ASSERT_TRUE(bookmark_model_->AddURL(bookmark_model_->bookmark_bar_node(), 0,
246 title3, url3)); 246 title3, url3));
247 // Only use the HistoryBackend to generate the test data. 247 // Only use the HistoryBackend to generate the test data.
248 // HistoryBackend will shutdown after that. 248 // HistoryBackend will shutdown after that.
249 { 249 {
250 scoped_refptr<HistoryBackend> history_backend; 250 scoped_refptr<HistoryBackend> history_backend;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 EXPECT_EQ(0, j->favicon_id_); 359 EXPECT_EQ(0, j->favicon_id_);
360 EXPECT_TRUE(j->bookmark_); 360 EXPECT_TRUE(j->bookmark_);
361 } 361 }
362 362
363 TEST_F(AndroidProviderBackendTest, QueryHistoryAndBookmarks) { 363 TEST_F(AndroidProviderBackendTest, QueryHistoryAndBookmarks) {
364 GURL url1("http://www.cnn.com"); 364 GURL url1("http://www.cnn.com");
365 const base::string16 title1(UTF8ToUTF16("cnn")); 365 const base::string16 title1(UTF8ToUTF16("cnn"));
366 std::vector<VisitInfo> visits1; 366 std::vector<VisitInfo> visits1;
367 Time last_visited1 = Time::Now() - TimeDelta::FromDays(1); 367 Time last_visited1 = Time::Now() - TimeDelta::FromDays(1);
368 Time created1 = last_visited1 - TimeDelta::FromDays(20); 368 Time created1 = last_visited1 - TimeDelta::FromDays(20);
369 visits1.push_back(VisitInfo(created1, content::PAGE_TRANSITION_LINK)); 369 visits1.push_back(VisitInfo(created1, ui::PAGE_TRANSITION_LINK));
370 visits1.push_back(VisitInfo(last_visited1 - TimeDelta::FromDays(1), 370 visits1.push_back(VisitInfo(last_visited1 - TimeDelta::FromDays(1),
371 content::PAGE_TRANSITION_LINK)); 371 ui::PAGE_TRANSITION_LINK));
372 visits1.push_back(VisitInfo(last_visited1, content::PAGE_TRANSITION_LINK)); 372 visits1.push_back(VisitInfo(last_visited1, ui::PAGE_TRANSITION_LINK));
373 373
374 GURL url2("http://www.example.com"); 374 GURL url2("http://www.example.com");
375 std::vector<VisitInfo> visits2; 375 std::vector<VisitInfo> visits2;
376 const base::string16 title2(UTF8ToUTF16("example")); 376 const base::string16 title2(UTF8ToUTF16("example"));
377 Time last_visited2 = Time::Now(); 377 Time last_visited2 = Time::Now();
378 Time created2 = last_visited2 - TimeDelta::FromDays(10); 378 Time created2 = last_visited2 - TimeDelta::FromDays(10);
379 visits2.push_back(VisitInfo(created2, content::PAGE_TRANSITION_LINK)); 379 visits2.push_back(VisitInfo(created2, ui::PAGE_TRANSITION_LINK));
380 visits2.push_back(VisitInfo(last_visited2 - TimeDelta::FromDays(5), 380 visits2.push_back(VisitInfo(last_visited2 - TimeDelta::FromDays(5),
381 content::PAGE_TRANSITION_LINK)); 381 ui::PAGE_TRANSITION_LINK));
382 visits2.push_back(VisitInfo(last_visited2, content::PAGE_TRANSITION_LINK)); 382 visits2.push_back(VisitInfo(last_visited2, ui::PAGE_TRANSITION_LINK));
383 383
384 // Only use the HistoryBackend to generate the test data. 384 // Only use the HistoryBackend to generate the test data.
385 // HistoryBackend will shutdown after that. 385 // HistoryBackend will shutdown after that.
386 { 386 {
387 scoped_refptr<HistoryBackend> history_backend; 387 scoped_refptr<HistoryBackend> history_backend;
388 history_backend = new HistoryBackend( 388 history_backend = new HistoryBackend(
389 temp_dir_.path(), new AndroidProviderBackendDelegate(), history_client_); 389 temp_dir_.path(), new AndroidProviderBackendDelegate(), history_client_);
390 history_backend->Init(std::string(), false); 390 history_backend->Init(std::string(), false);
391 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED); 391 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED);
392 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED); 392 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED);
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); 1795 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0)));
1796 EXPECT_FALSE(statement->statement()->Step()); 1796 EXPECT_FALSE(statement->statement()->Step());
1797 } 1797 }
1798 1798
1799 TEST_F(AndroidProviderBackendTest, QueryWithoutThumbnailDB) { 1799 TEST_F(AndroidProviderBackendTest, QueryWithoutThumbnailDB) {
1800 GURL url1("http://www.cnn.com"); 1800 GURL url1("http://www.cnn.com");
1801 const base::string16 title1(UTF8ToUTF16("cnn")); 1801 const base::string16 title1(UTF8ToUTF16("cnn"));
1802 std::vector<VisitInfo> visits1; 1802 std::vector<VisitInfo> visits1;
1803 Time last_visited1 = Time::Now() - TimeDelta::FromDays(1); 1803 Time last_visited1 = Time::Now() - TimeDelta::FromDays(1);
1804 Time created1 = last_visited1 - TimeDelta::FromDays(20); 1804 Time created1 = last_visited1 - TimeDelta::FromDays(20);
1805 visits1.push_back(VisitInfo(created1, content::PAGE_TRANSITION_LINK)); 1805 visits1.push_back(VisitInfo(created1, ui::PAGE_TRANSITION_LINK));
1806 visits1.push_back(VisitInfo(last_visited1 - TimeDelta::FromDays(1), 1806 visits1.push_back(VisitInfo(last_visited1 - TimeDelta::FromDays(1),
1807 content::PAGE_TRANSITION_LINK)); 1807 ui::PAGE_TRANSITION_LINK));
1808 visits1.push_back(VisitInfo(last_visited1, content::PAGE_TRANSITION_LINK)); 1808 visits1.push_back(VisitInfo(last_visited1, ui::PAGE_TRANSITION_LINK));
1809 1809
1810 GURL url2("http://www.example.com"); 1810 GURL url2("http://www.example.com");
1811 std::vector<VisitInfo> visits2; 1811 std::vector<VisitInfo> visits2;
1812 const base::string16 title2(UTF8ToUTF16("example")); 1812 const base::string16 title2(UTF8ToUTF16("example"));
1813 Time last_visited2 = Time::Now(); 1813 Time last_visited2 = Time::Now();
1814 Time created2 = last_visited2 - TimeDelta::FromDays(10); 1814 Time created2 = last_visited2 - TimeDelta::FromDays(10);
1815 visits2.push_back(VisitInfo(created2, content::PAGE_TRANSITION_LINK)); 1815 visits2.push_back(VisitInfo(created2, ui::PAGE_TRANSITION_LINK));
1816 visits2.push_back(VisitInfo(last_visited2 - TimeDelta::FromDays(5), 1816 visits2.push_back(VisitInfo(last_visited2 - TimeDelta::FromDays(5),
1817 content::PAGE_TRANSITION_LINK)); 1817 ui::PAGE_TRANSITION_LINK));
1818 visits2.push_back(VisitInfo(last_visited2, content::PAGE_TRANSITION_LINK)); 1818 visits2.push_back(VisitInfo(last_visited2, ui::PAGE_TRANSITION_LINK));
1819 1819
1820 // Only use the HistoryBackend to generate the test data. 1820 // Only use the HistoryBackend to generate the test data.
1821 // HistoryBackend will shutdown after that. 1821 // HistoryBackend will shutdown after that.
1822 { 1822 {
1823 scoped_refptr<HistoryBackend> history_backend; 1823 scoped_refptr<HistoryBackend> history_backend;
1824 history_backend = new HistoryBackend( 1824 history_backend = new HistoryBackend(
1825 temp_dir_.path(), new AndroidProviderBackendDelegate(), history_client_); 1825 temp_dir_.path(), new AndroidProviderBackendDelegate(), history_client_);
1826 history_backend->Init(std::string(), false); 1826 history_backend->Init(std::string(), false);
1827 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED); 1827 history_backend->AddVisits(url1, visits1, history::SOURCE_SYNCED);
1828 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED); 1828 history_backend->AddVisits(url2, visits2, history::SOURCE_SYNCED);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 update_args, &update_count)); 2104 update_args, &update_count));
2105 // Verify notifications. 2105 // Verify notifications.
2106 EXPECT_FALSE(delegate_.deleted_details()); 2106 EXPECT_FALSE(delegate_.deleted_details());
2107 ASSERT_TRUE(delegate_.modified_details()); 2107 ASSERT_TRUE(delegate_.modified_details());
2108 ASSERT_EQ(1u, delegate_.modified_details()->changed_urls.size()); 2108 ASSERT_EQ(1u, delegate_.modified_details()->changed_urls.size());
2109 // No favicon will be updated as thumbnail database is missing. 2109 // No favicon will be updated as thumbnail database is missing.
2110 EXPECT_FALSE(delegate_.favicon_changed()); 2110 EXPECT_FALSE(delegate_.favicon_changed());
2111 } 2111 }
2112 2112
2113 } // namespace history 2113 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/android/android_provider_backend.cc ('k') | chrome/browser/history/android/visit_sql_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698