Chromium Code Reviews| 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/browsing_data/cookies_tree_model.h" | 5 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 mock_browsing_data_quota_helper_ = nullptr; | 101 mock_browsing_data_quota_helper_ = nullptr; |
| 102 mock_browsing_data_file_system_helper_ = nullptr; | 102 mock_browsing_data_file_system_helper_ = nullptr; |
| 103 mock_browsing_data_indexed_db_helper_ = nullptr; | 103 mock_browsing_data_indexed_db_helper_ = nullptr; |
| 104 mock_browsing_data_appcache_helper_ = nullptr; | 104 mock_browsing_data_appcache_helper_ = nullptr; |
| 105 mock_browsing_data_session_storage_helper_ = nullptr; | 105 mock_browsing_data_session_storage_helper_ = nullptr; |
| 106 mock_browsing_data_local_storage_helper_ = nullptr; | 106 mock_browsing_data_local_storage_helper_ = nullptr; |
| 107 mock_browsing_data_database_helper_ = nullptr; | 107 mock_browsing_data_database_helper_ = nullptr; |
| 108 mock_browsing_data_flash_lso_helper_ = nullptr; | 108 mock_browsing_data_flash_lso_helper_ = nullptr; |
| 109 base::MessageLoop::current()->RunUntilIdle(); | 109 base::MessageLoop::current()->RunUntilIdle(); |
| 110 } | 110 } |
| 111 | |
| 112 std::unique_ptr<CookiesTreeModel> CreateCookiesTreeModelWithInitialSample() { | 111 std::unique_ptr<CookiesTreeModel> CreateCookiesTreeModelWithInitialSample() { |
| 113 LocalDataContainer* container = | 112 LocalDataContainer* container = |
| 114 new LocalDataContainer(mock_browsing_data_cookie_helper_.get(), | 113 new LocalDataContainer(mock_browsing_data_cookie_helper_.get(), |
| 115 mock_browsing_data_database_helper_.get(), | 114 mock_browsing_data_database_helper_.get(), |
| 116 mock_browsing_data_local_storage_helper_.get(), | 115 mock_browsing_data_local_storage_helper_.get(), |
| 117 mock_browsing_data_session_storage_helper_.get(), | 116 mock_browsing_data_session_storage_helper_.get(), |
| 118 mock_browsing_data_appcache_helper_.get(), | 117 mock_browsing_data_appcache_helper_.get(), |
| 119 mock_browsing_data_indexed_db_helper_.get(), | 118 mock_browsing_data_indexed_db_helper_.get(), |
| 120 mock_browsing_data_file_system_helper_.get(), | 119 mock_browsing_data_file_system_helper_.get(), |
| 121 mock_browsing_data_quota_helper_.get(), | 120 mock_browsing_data_quota_helper_.get(), |
| (...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1647 mock_browsing_data_cache_storage_helper_.get(), | 1646 mock_browsing_data_cache_storage_helper_.get(), |
| 1648 mock_browsing_data_flash_lso_helper_.get()); | 1647 mock_browsing_data_flash_lso_helper_.get()); |
| 1649 CookiesTreeModel cookies_model(container, special_storage_policy(), false); | 1648 CookiesTreeModel cookies_model(container, special_storage_policy(), false); |
| 1650 | 1649 |
| 1651 mock_browsing_data_cookie_helper_-> | 1650 mock_browsing_data_cookie_helper_-> |
| 1652 AddCookieSamples(GURL(), "A=1"); | 1651 AddCookieSamples(GURL(), "A=1"); |
| 1653 mock_browsing_data_cookie_helper_->Notify(); | 1652 mock_browsing_data_cookie_helper_->Notify(); |
| 1654 EXPECT_EQ("A", GetDisplayedCookies(&cookies_model)); | 1653 EXPECT_EQ("A", GetDisplayedCookies(&cookies_model)); |
| 1655 } | 1654 } |
| 1656 | 1655 |
| 1656 TEST_F(CookiesTreeModelTest, Suborigins) { | |
| 1657 LocalDataContainer* container = | |
| 1658 new LocalDataContainer(mock_browsing_data_cookie_helper_.get(), | |
| 1659 mock_browsing_data_database_helper_.get(), | |
| 1660 mock_browsing_data_local_storage_helper_.get(), | |
| 1661 mock_browsing_data_session_storage_helper_.get(), | |
| 1662 mock_browsing_data_appcache_helper_.get(), | |
| 1663 mock_browsing_data_indexed_db_helper_.get(), | |
| 1664 mock_browsing_data_file_system_helper_.get(), | |
| 1665 mock_browsing_data_quota_helper_.get(), | |
| 1666 mock_browsing_data_channel_id_helper_.get(), | |
| 1667 mock_browsing_data_service_worker_helper_.get(), | |
| 1668 mock_browsing_data_cache_storage_helper_.get(), | |
| 1669 mock_browsing_data_flash_lso_helper_.get()); | |
| 1670 CookiesTreeModel cookies_model(container, special_storage_policy(), false); | |
| 1671 | |
| 1672 mock_browsing_data_local_storage_helper_ | |
| 1673 ->AddLocalStorageSamplesWithSuborigins(); | |
| 1674 mock_browsing_data_local_storage_helper_->Notify(); | |
| 1675 { | |
| 1676 SCOPED_TRACE( | |
| 1677 "Suborigins get their own storage partitions and are folded into their " | |
| 1678 "respective hosts"); | |
| 1679 // root | |
| 1680 // host4 -> local storage -> http://foobar_host4:4 | |
| 1681 // -> http://host4:4 | |
| 1682 // host3 -> local storage -> http://foobar_host3:3 | |
| 1683 // host2 -> local storage -> http://host2:2 | |
| 1684 // host1 -> local storage -> http://host1:1 | |
| 1685 EXPECT_EQ(14, cookies_model.GetRoot()->GetTotalNodeCount()); | |
| 1686 EXPECT_EQ( | |
| 1687 "http://host1:1/,http://host2:2/,http://foobar_host3:3/,http://" | |
|
msramek
2016/05/25 16:09:29
nit: line break after the last comma rather than t
jww
2016/05/25 20:46:22
Done.
| |
| 1688 "foobar_host4:4/,http://host4:4/", | |
| 1689 GetDisplayedLocalStorages(&cookies_model)); | |
| 1690 // Delete host4, which should delete foobar_host4:4 in addition to host4:4 | |
| 1691 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(3)); | |
| 1692 EXPECT_EQ(10, cookies_model.GetRoot()->GetTotalNodeCount()); | |
| 1693 } | |
| 1694 } | |
| 1695 | |
| 1657 } // namespace | 1696 } // namespace |
| OLD | NEW |