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/browsing_data_local_storage_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
6 | 6 |
7 #include "chrome/test/base/testing_profile.h" | 7 #include "chrome/test/base/testing_profile.h" |
8 #include "content/public/test/test_browser_thread_bundle.h" | 8 #include "content/public/test/test_browser_thread_bundle.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( | 22 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( |
23 new CannedBrowsingDataLocalStorageHelper(&profile)); | 23 new CannedBrowsingDataLocalStorageHelper(&profile)); |
24 | 24 |
25 ASSERT_TRUE(helper->empty()); | 25 ASSERT_TRUE(helper->empty()); |
26 helper->AddLocalStorage(origin); | 26 helper->AddLocalStorage(origin); |
27 ASSERT_FALSE(helper->empty()); | 27 ASSERT_FALSE(helper->empty()); |
28 helper->Reset(); | 28 helper->Reset(); |
29 ASSERT_TRUE(helper->empty()); | 29 ASSERT_TRUE(helper->empty()); |
30 } | 30 } |
31 | 31 |
| 32 TEST_F(CannedBrowsingDataLocalStorageTest, Delete) { |
| 33 TestingProfile profile; |
| 34 |
| 35 const GURL origin1("http://host1:9000"); |
| 36 const GURL origin2("http://example.com"); |
| 37 const GURL origin3("http://foo.example.com"); |
| 38 |
| 39 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( |
| 40 new CannedBrowsingDataLocalStorageHelper(&profile)); |
| 41 |
| 42 EXPECT_TRUE(helper->empty()); |
| 43 helper->AddLocalStorage(origin1); |
| 44 helper->AddLocalStorage(origin2); |
| 45 helper->AddLocalStorage(origin3); |
| 46 EXPECT_EQ(3u, helper->GetLocalStorageCount()); |
| 47 helper->DeleteOrigin(origin2); |
| 48 EXPECT_EQ(2u, helper->GetLocalStorageCount()); |
| 49 helper->DeleteOrigin(origin1); |
| 50 EXPECT_EQ(1u, helper->GetLocalStorageCount()); |
| 51 } |
| 52 |
32 TEST_F(CannedBrowsingDataLocalStorageTest, IgnoreExtensionsAndDevTools) { | 53 TEST_F(CannedBrowsingDataLocalStorageTest, IgnoreExtensionsAndDevTools) { |
33 TestingProfile profile; | 54 TestingProfile profile; |
34 | 55 |
35 const GURL origin1("chrome-extension://abcdefghijklmnopqrstuvwxyz/"); | 56 const GURL origin1("chrome-extension://abcdefghijklmnopqrstuvwxyz/"); |
36 const GURL origin2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/"); | 57 const GURL origin2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/"); |
37 | 58 |
38 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( | 59 scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper( |
39 new CannedBrowsingDataLocalStorageHelper(&profile)); | 60 new CannedBrowsingDataLocalStorageHelper(&profile)); |
40 | 61 |
41 ASSERT_TRUE(helper->empty()); | 62 ASSERT_TRUE(helper->empty()); |
42 helper->AddLocalStorage(origin1); | 63 helper->AddLocalStorage(origin1); |
43 ASSERT_TRUE(helper->empty()); | 64 ASSERT_TRUE(helper->empty()); |
44 helper->AddLocalStorage(origin2); | 65 helper->AddLocalStorage(origin2); |
45 ASSERT_TRUE(helper->empty()); | 66 ASSERT_TRUE(helper->empty()); |
46 } | 67 } |
47 | 68 |
48 } // namespace | 69 } // namespace |
OLD | NEW |