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 "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/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 row2.set_raw_url("http://www.example.com"); | 1629 row2.set_raw_url("http://www.example.com"); |
1630 row2.set_url(GURL("http://www.example.com")); | 1630 row2.set_url(GURL("http://www.example.com")); |
1631 row2.set_last_visit_time(Time::Now() - TimeDelta::FromDays(10)); | 1631 row2.set_last_visit_time(Time::Now() - TimeDelta::FromDays(10)); |
1632 row2.set_is_bookmark(false); | 1632 row2.set_is_bookmark(false); |
1633 row2.set_title(UTF8ToUTF16("example")); | 1633 row2.set_title(UTF8ToUTF16("example")); |
1634 ASSERT_TRUE(backend->InsertHistoryAndBookmark(row2)); | 1634 ASSERT_TRUE(backend->InsertHistoryAndBookmark(row2)); |
1635 EXPECT_EQ(history_transaction, history_db_.transaction_nesting()); | 1635 EXPECT_EQ(history_transaction, history_db_.transaction_nesting()); |
1636 EXPECT_EQ(thumbnail_transaction, thumbnail_db_.transaction_nesting()); | 1636 EXPECT_EQ(thumbnail_transaction, thumbnail_db_.transaction_nesting()); |
1637 } | 1637 } |
1638 | 1638 |
| 1639 TEST_F(AndroidProviderBackendTest, AndroidCTSComplianceFolderColumnExists) { |
| 1640 // This is test is used to verify the 'folder' column exists, all bookmarks |
| 1641 // returned when folder is 0 and the non bookmark rows returned when folder |
| 1642 // is 1. |
| 1643 ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, bookmark_temp_)); |
| 1644 ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL, |
| 1645 &history_db_)); |
| 1646 scoped_ptr<AndroidProviderBackend> backend( |
| 1647 new AndroidProviderBackend(android_cache_db_name_, &history_db_, |
| 1648 &thumbnail_db_, bookmark_model_, &delegate_)); |
| 1649 HistoryAndBookmarkRow row1; |
| 1650 row1.set_raw_url("cnn.com"); |
| 1651 row1.set_url(GURL("http://cnn.com")); |
| 1652 row1.set_last_visit_time(Time::Now() - TimeDelta::FromDays(1)); |
| 1653 row1.set_created(Time::Now() - TimeDelta::FromDays(20)); |
| 1654 row1.set_visit_count(10); |
| 1655 row1.set_is_bookmark(true); |
| 1656 row1.set_title(UTF8ToUTF16("cnn")); |
| 1657 |
| 1658 HistoryAndBookmarkRow row2; |
| 1659 row2.set_raw_url("http://www.example.com"); |
| 1660 row2.set_url(GURL("http://www.example.com")); |
| 1661 row2.set_last_visit_time(Time::Now() - TimeDelta::FromDays(10)); |
| 1662 row2.set_is_bookmark(false); |
| 1663 row2.set_title(UTF8ToUTF16("example")); |
| 1664 std::vector<unsigned char> data; |
| 1665 data.push_back('1'); |
| 1666 row2.set_favicon(data); |
| 1667 |
| 1668 AndroidURLID id1 = backend->InsertHistoryAndBookmark(row1); |
| 1669 ASSERT_TRUE(id1); |
| 1670 AndroidURLID id2 = backend->InsertHistoryAndBookmark(row2); |
| 1671 ASSERT_TRUE(id2); |
| 1672 ui_test_utils::RunAllPendingInMessageLoop(); |
| 1673 |
| 1674 // Query by folder=0, the row1 should returned. |
| 1675 std::vector<HistoryAndBookmarkRow::ColumnID> projections; |
| 1676 |
| 1677 projections.push_back(HistoryAndBookmarkRow::URL); |
| 1678 |
| 1679 scoped_ptr<AndroidStatement> statement(backend->QueryHistoryAndBookmarks( |
| 1680 projections, std::string("folder=0"), std::vector<string16>(), |
| 1681 std::string("url ASC"))); |
| 1682 ASSERT_TRUE(statement->statement()->Step()); |
| 1683 EXPECT_EQ(row1.raw_url(), statement->statement()->ColumnString(0)); |
| 1684 EXPECT_FALSE(statement->statement()->Step()); |
| 1685 |
| 1686 // Query by folder=1, the row2 should returned. |
| 1687 statement.reset(backend->QueryHistoryAndBookmarks( |
| 1688 projections, std::string("folder=1"), std::vector<string16>(), |
| 1689 std::string("url ASC"))); |
| 1690 ASSERT_TRUE(statement->statement()->Step()); |
| 1691 EXPECT_EQ(row2.url(), GURL(statement->statement()->ColumnString(0))); |
| 1692 EXPECT_FALSE(statement->statement()->Step()); |
| 1693 } |
| 1694 |
1639 } // namespace history | 1695 } // namespace history |
OLD | NEW |