diff options
author | michaelbai@chromium.org <michaelbai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 23:06:10 +0000 |
---|---|---|
committer | michaelbai@chromium.org <michaelbai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 23:06:10 +0000 |
commit | ea060bf7becb87861883b39d1050107f1cc7c1c2 (patch) | |
tree | 3bf60165b279afe59fe9a75bcfe652ab71b19025 | |
parent | 5b27d33b00bf0ad9d6c82a5b39697136c3248919 (diff) | |
download | chromium_src-ea060bf7becb87861883b39d1050107f1cc7c1c2.zip chromium_src-ea060bf7becb87861883b39d1050107f1cc7c1c2.tar.gz chromium_src-ea060bf7becb87861883b39d1050107f1cc7c1c2.tar.bz2 |
Added 'folder' column in virtual table.
Added 'folder' column to virtual table required to pass Android CTS test.
BUG=
TEST=Add a new test.
Review URL: http://codereview.chromium.org/10162019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133797 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/history/android/android_provider_backend.cc | 13 | ||||
-rw-r--r-- | chrome/browser/history/android/android_provider_backend_unittest.cc | 56 |
2 files changed, 66 insertions, 3 deletions
diff --git a/chrome/browser/history/android/android_provider_backend.cc b/chrome/browser/history/android/android_provider_backend.cc index 8f591ee..5d6a647 100644 --- a/chrome/browser/history/android/android_provider_backend.cc +++ b/chrome/browser/history/android/android_provider_backend.cc @@ -34,10 +34,17 @@ const char* kVirtualHistoryAndBookmarkTable = "android_cache_db.bookmark_cache.last_visit_time AS date, " "android_cache_db.bookmark_cache.bookmark AS bookmark, " "android_cache_db.bookmark_cache.favicon_id AS favicon, " - "urls.id AS url_id, urls.url AS urls_url " + "urls.id AS url_id, urls.url AS urls_url, " + // TODO (michaelbai) : Remove folder column once we remove it from Android + // framework. + // Android framework assumes 'folder' column exist in the table, the row is + // the bookmark once folder is 0, though it is not part of public API, it + // has to be added and set as 0 when the row is bookmark. + "(CASE WHEN android_cache_db.bookmark_cache.bookmark IS 0 " + "THEN 1 ELSE 0 END) as folder " "FROM (android_urls JOIN urls on (android_urls.url_id = urls.id) " - "LEFT JOIN android_cache_db.bookmark_cache AS bookmark_cache " - "on (android_urls.url_id = bookmark_cache.url_id))"; + "LEFT JOIN android_cache_db.bookmark_cache " + "on (android_urls.url_id = android_cache_db.bookmark_cache.url_id))"; const char * kURLUpdateClause = "SELECT urls.id, urls.last_visit_time, created_time, urls.url " diff --git a/chrome/browser/history/android/android_provider_backend_unittest.cc b/chrome/browser/history/android/android_provider_backend_unittest.cc index b97475d..4517305 100644 --- a/chrome/browser/history/android/android_provider_backend_unittest.cc +++ b/chrome/browser/history/android/android_provider_backend_unittest.cc @@ -1673,4 +1673,60 @@ TEST_F(AndroidProviderBackendTest, TestAndroidCTSComplianceForZeroVisitCount) { EXPECT_EQ(url_row.visit_count(), statement->statement()->ColumnInt(5)); } +TEST_F(AndroidProviderBackendTest, AndroidCTSComplianceFolderColumnExists) { + // This is test is used to verify the 'folder' column exists, all bookmarks + // returned when folder is 0 and the non bookmark rows returned when folder + // is 1. + ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, bookmark_temp_)); + ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL, + &history_db_)); + scoped_ptr<AndroidProviderBackend> backend( + new AndroidProviderBackend(android_cache_db_name_, &history_db_, + &thumbnail_db_, bookmark_model_, &delegate_)); + HistoryAndBookmarkRow row1; + row1.set_raw_url("cnn.com"); + row1.set_url(GURL("http://cnn.com")); + row1.set_last_visit_time(Time::Now() - TimeDelta::FromDays(1)); + row1.set_created(Time::Now() - TimeDelta::FromDays(20)); + row1.set_visit_count(10); + row1.set_is_bookmark(true); + row1.set_title(UTF8ToUTF16("cnn")); + + HistoryAndBookmarkRow row2; + row2.set_raw_url("http://www.example.com"); + row2.set_url(GURL("http://www.example.com")); + row2.set_last_visit_time(Time::Now() - TimeDelta::FromDays(10)); + row2.set_is_bookmark(false); + row2.set_title(UTF8ToUTF16("example")); + std::vector<unsigned char> data; + data.push_back('1'); + row2.set_favicon(data); + + AndroidURLID id1 = backend->InsertHistoryAndBookmark(row1); + ASSERT_TRUE(id1); + AndroidURLID id2 = backend->InsertHistoryAndBookmark(row2); + ASSERT_TRUE(id2); + ui_test_utils::RunAllPendingInMessageLoop(); + + // Query by folder=0, the row1 should returned. + std::vector<HistoryAndBookmarkRow::ColumnID> projections; + + projections.push_back(HistoryAndBookmarkRow::URL); + + scoped_ptr<AndroidStatement> statement(backend->QueryHistoryAndBookmarks( + projections, std::string("folder=0"), std::vector<string16>(), + std::string("url ASC"))); + ASSERT_TRUE(statement->statement()->Step()); + EXPECT_EQ(row1.raw_url(), statement->statement()->ColumnString(0)); + EXPECT_FALSE(statement->statement()->Step()); + + // Query by folder=1, the row2 should returned. + statement.reset(backend->QueryHistoryAndBookmarks( + projections, std::string("folder=1"), std::vector<string16>(), + std::string("url ASC"))); + ASSERT_TRUE(statement->statement()->Step()); + EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); + EXPECT_FALSE(statement->statement()->Step()); +} + } // namespace history |