| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/browsing_data_database_helper.h" | 7 #include "chrome/browser/browsing_data_database_helper.h" |
| 8 #include "chrome/browser/browsing_data_helper_browsertest.h" | 8 #include "chrome/browser/browsing_data_helper_browsertest.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // Called back by BrowsingDataDatabaseHelper on the UI thread once the database | 52 // Called back by BrowsingDataDatabaseHelper on the UI thread once the database |
| 53 // information has been retrieved. | 53 // information has been retrieved. |
| 54 class StopTestOnCallback { | 54 class StopTestOnCallback { |
| 55 public: | 55 public: |
| 56 explicit StopTestOnCallback( | 56 explicit StopTestOnCallback( |
| 57 BrowsingDataDatabaseHelper* database_helper) | 57 BrowsingDataDatabaseHelper* database_helper) |
| 58 : database_helper_(database_helper) { | 58 : database_helper_(database_helper) { |
| 59 DCHECK(database_helper_); | 59 DCHECK(database_helper_); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void Callback(const std::vector<BrowsingDataDatabaseHelper::DatabaseInfo>& | 62 void Callback(const std::list<BrowsingDataDatabaseHelper::DatabaseInfo>& |
| 63 database_info_list) { | 63 database_info_list) { |
| 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 65 ASSERT_EQ(1UL, database_info_list.size()); | 65 ASSERT_EQ(1UL, database_info_list.size()); |
| 66 EXPECT_EQ(std::string(kTestIdentifier1), | 66 EXPECT_EQ(std::string(kTestIdentifier1), |
| 67 database_info_list.at(0).origin_identifier); | 67 database_info_list.begin()->origin_identifier); |
| 68 MessageLoop::current()->Quit(); | 68 MessageLoop::current()->Quit(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 BrowsingDataDatabaseHelper* database_helper_; | 72 BrowsingDataDatabaseHelper* database_helper_; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 // Flaky on Win/Mac/Linux: http://crbug.com/92460 | 75 // Flaky on Win/Mac/Linux: http://crbug.com/92460 |
| 76 IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, DISABLED_FetchData) { | 76 IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, DISABLED_FetchData) { |
| 77 CreateDatabases(); | 77 CreateDatabases(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 96 scoped_refptr<CannedBrowsingDataDatabaseHelper> helper( | 96 scoped_refptr<CannedBrowsingDataDatabaseHelper> helper( |
| 97 new CannedBrowsingDataDatabaseHelper(browser()->profile())); | 97 new CannedBrowsingDataDatabaseHelper(browser()->profile())); |
| 98 helper->AddDatabase(origin1, db1, ""); | 98 helper->AddDatabase(origin1, db1, ""); |
| 99 helper->AddDatabase(origin1, db2, ""); | 99 helper->AddDatabase(origin1, db2, ""); |
| 100 helper->AddDatabase(origin2, db3, ""); | 100 helper->AddDatabase(origin2, db3, ""); |
| 101 | 101 |
| 102 TestCompletionCallback callback; | 102 TestCompletionCallback callback; |
| 103 helper->StartFetching( | 103 helper->StartFetching( |
| 104 NewCallback(&callback, &TestCompletionCallback::callback)); | 104 NewCallback(&callback, &TestCompletionCallback::callback)); |
| 105 | 105 |
| 106 std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> result = | 106 std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = |
| 107 callback.result(); | 107 callback.result(); |
| 108 | 108 |
| 109 ASSERT_EQ(3u, result.size()); | 109 ASSERT_EQ(3u, result.size()); |
| 110 EXPECT_STREQ(origin_str1, result[0].origin_identifier.c_str()); | 110 std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator info = |
| 111 EXPECT_STREQ(db1, result[0].database_name.c_str()); | 111 result.begin(); |
| 112 EXPECT_STREQ(origin_str1, result[1].origin_identifier.c_str()); | 112 EXPECT_STREQ(origin_str1, info->origin_identifier.c_str()); |
| 113 EXPECT_STREQ(db2, result[1].database_name.c_str()); | 113 EXPECT_STREQ(db1, info->database_name.c_str()); |
| 114 EXPECT_STREQ(origin_str2, result[2].origin_identifier.c_str()); | 114 info++; |
| 115 EXPECT_STREQ(db3, result[2].database_name.c_str()); | 115 EXPECT_STREQ(origin_str1, info->origin_identifier.c_str()); |
| 116 EXPECT_STREQ(db2, info->database_name.c_str()); |
| 117 info++; |
| 118 EXPECT_STREQ(origin_str2, info->origin_identifier.c_str()); |
| 119 EXPECT_STREQ(db3, info->database_name.c_str()); |
| 116 } | 120 } |
| 117 | 121 |
| 118 IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedUnique) { | 122 IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedUnique) { |
| 119 const GURL origin("http://host1:1/"); | 123 const GURL origin("http://host1:1/"); |
| 120 const char origin_str[] = "http_host1_1"; | 124 const char origin_str[] = "http_host1_1"; |
| 121 const char db[] = "db1"; | 125 const char db[] = "db1"; |
| 122 | 126 |
| 123 scoped_refptr<CannedBrowsingDataDatabaseHelper> helper( | 127 scoped_refptr<CannedBrowsingDataDatabaseHelper> helper( |
| 124 new CannedBrowsingDataDatabaseHelper(browser()->profile())); | 128 new CannedBrowsingDataDatabaseHelper(browser()->profile())); |
| 125 helper->AddDatabase(origin, db, ""); | 129 helper->AddDatabase(origin, db, ""); |
| 126 helper->AddDatabase(origin, db, ""); | 130 helper->AddDatabase(origin, db, ""); |
| 127 | 131 |
| 128 TestCompletionCallback callback; | 132 TestCompletionCallback callback; |
| 129 helper->StartFetching( | 133 helper->StartFetching( |
| 130 NewCallback(&callback, &TestCompletionCallback::callback)); | 134 NewCallback(&callback, &TestCompletionCallback::callback)); |
| 131 | 135 |
| 132 std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> result = | 136 std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = |
| 133 callback.result(); | 137 callback.result(); |
| 134 | 138 |
| 135 ASSERT_EQ(1u, result.size()); | 139 ASSERT_EQ(1u, result.size()); |
| 136 EXPECT_STREQ(origin_str, result[0].origin_identifier.c_str()); | 140 EXPECT_STREQ(origin_str, result.begin()->origin_identifier.c_str()); |
| 137 EXPECT_STREQ(db, result[0].database_name.c_str()); | 141 EXPECT_STREQ(db, result.begin()->database_name.c_str()); |
| 138 } | 142 } |
| 139 } // namespace | 143 } // namespace |
| OLD | NEW |