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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/scoped_temp_dir.h" | 6 #include "base/scoped_temp_dir.h" |
7 #include "chrome/test/base/ui_test_utils.h" | 7 #include "chrome/test/base/ui_test_utils.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 9 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
11 #include "content/test/test_browser_context.h" | 11 #include "content/public/test/test_browser_context.h" |
12 #include "webkit/database/database_util.h" | 12 #include "webkit/database/database_util.h" |
13 #include "webkit/quota/mock_special_storage_policy.h" | 13 #include "webkit/quota/mock_special_storage_policy.h" |
14 #include "webkit/quota/special_storage_policy.h" | 14 #include "webkit/quota/special_storage_policy.h" |
15 | 15 |
16 using content::BrowserContext; | 16 using content::BrowserContext; |
17 using content::BrowserThread; | 17 using content::BrowserThread; |
18 using content::BrowserThreadImpl; | 18 using content::BrowserThreadImpl; |
19 using webkit_database::DatabaseUtil; | 19 using webkit_database::DatabaseUtil; |
20 | 20 |
21 class IndexedDBTest : public testing::Test { | 21 class IndexedDBTest : public testing::Test { |
(...skipping 17 matching lines...) Expand all Loading... |
39 TEST_F(IndexedDBTest, ClearLocalState) { | 39 TEST_F(IndexedDBTest, ClearLocalState) { |
40 ScopedTempDir temp_dir; | 40 ScopedTempDir temp_dir; |
41 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 41 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
42 | 42 |
43 FilePath protected_path; | 43 FilePath protected_path; |
44 FilePath unprotected_path; | 44 FilePath unprotected_path; |
45 | 45 |
46 // Create the scope which will ensure we run the destructor of the webkit | 46 // Create the scope which will ensure we run the destructor of the webkit |
47 // context which should trigger the clean up. | 47 // context which should trigger the clean up. |
48 { | 48 { |
49 TestBrowserContext browser_context; | 49 content::TestBrowserContext browser_context; |
50 | 50 |
51 // Test our assumptions about what is protected and what is not. | 51 // Test our assumptions about what is protected and what is not. |
52 const GURL kProtectedOrigin("https://foo/"); | 52 const GURL kProtectedOrigin("https://foo/"); |
53 const GURL kUnprotectedOrigin("http://foo/"); | 53 const GURL kUnprotectedOrigin("http://foo/"); |
54 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = | 54 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = |
55 new quota::MockSpecialStoragePolicy; | 55 new quota::MockSpecialStoragePolicy; |
56 special_storage_policy->AddProtected(kProtectedOrigin); | 56 special_storage_policy->AddProtected(kProtectedOrigin); |
57 browser_context.SetSpecialStoragePolicy(special_storage_policy); | 57 browser_context.SetSpecialStoragePolicy(special_storage_policy); |
58 quota::SpecialStoragePolicy* policy = | 58 quota::SpecialStoragePolicy* policy = |
59 browser_context.GetSpecialStoragePolicy(); | 59 browser_context.GetSpecialStoragePolicy(); |
(...skipping 28 matching lines...) Expand all Loading... |
88 TEST_F(IndexedDBTest, ClearSessionOnlyDatabases) { | 88 TEST_F(IndexedDBTest, ClearSessionOnlyDatabases) { |
89 ScopedTempDir temp_dir; | 89 ScopedTempDir temp_dir; |
90 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 90 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
91 | 91 |
92 FilePath normal_path; | 92 FilePath normal_path; |
93 FilePath session_only_path; | 93 FilePath session_only_path; |
94 | 94 |
95 // Create the scope which will ensure we run the destructor of the webkit | 95 // Create the scope which will ensure we run the destructor of the webkit |
96 // context which should trigger the clean up. | 96 // context which should trigger the clean up. |
97 { | 97 { |
98 TestBrowserContext browser_context; | 98 content::TestBrowserContext browser_context; |
99 | 99 |
100 const GURL kNormalOrigin("http://normal/"); | 100 const GURL kNormalOrigin("http://normal/"); |
101 const GURL kSessionOnlyOrigin("http://session-only/"); | 101 const GURL kSessionOnlyOrigin("http://session-only/"); |
102 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = | 102 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = |
103 new quota::MockSpecialStoragePolicy; | 103 new quota::MockSpecialStoragePolicy; |
104 special_storage_policy->AddSessionOnly(kSessionOnlyOrigin); | 104 special_storage_policy->AddSessionOnly(kSessionOnlyOrigin); |
105 | 105 |
106 // Create some indexedDB paths. | 106 // Create some indexedDB paths. |
107 // With the levelDB backend, these are directories. | 107 // With the levelDB backend, these are directories. |
108 IndexedDBContextImpl* idb_context = | 108 IndexedDBContextImpl* idb_context = |
(...skipping 22 matching lines...) Expand all Loading... |
131 TEST_F(IndexedDBTest, SaveSessionState) { | 131 TEST_F(IndexedDBTest, SaveSessionState) { |
132 ScopedTempDir temp_dir; | 132 ScopedTempDir temp_dir; |
133 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 133 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
134 | 134 |
135 FilePath normal_path; | 135 FilePath normal_path; |
136 FilePath session_only_path; | 136 FilePath session_only_path; |
137 | 137 |
138 // Create the scope which will ensure we run the destructor of the webkit | 138 // Create the scope which will ensure we run the destructor of the webkit |
139 // context. | 139 // context. |
140 { | 140 { |
141 TestBrowserContext browser_context; | 141 content::TestBrowserContext browser_context; |
142 | 142 |
143 const GURL kNormalOrigin("http://normal/"); | 143 const GURL kNormalOrigin("http://normal/"); |
144 const GURL kSessionOnlyOrigin("http://session-only/"); | 144 const GURL kSessionOnlyOrigin("http://session-only/"); |
145 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = | 145 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = |
146 new quota::MockSpecialStoragePolicy; | 146 new quota::MockSpecialStoragePolicy; |
147 special_storage_policy->AddSessionOnly(kSessionOnlyOrigin); | 147 special_storage_policy->AddSessionOnly(kSessionOnlyOrigin); |
148 | 148 |
149 // Create some indexedDB paths. | 149 // Create some indexedDB paths. |
150 // With the levelDB backend, these are directories. | 150 // With the levelDB backend, these are directories. |
151 IndexedDBContextImpl* idb_context = | 151 IndexedDBContextImpl* idb_context = |
(...skipping 17 matching lines...) Expand all Loading... |
169 message_loop_.RunAllPending(); | 169 message_loop_.RunAllPending(); |
170 } | 170 } |
171 | 171 |
172 // Make sure we wait until the destructor has run. | 172 // Make sure we wait until the destructor has run. |
173 message_loop_.RunAllPending(); | 173 message_loop_.RunAllPending(); |
174 | 174 |
175 // No data was cleared because of SaveSessionState. | 175 // No data was cleared because of SaveSessionState. |
176 EXPECT_TRUE(file_util::DirectoryExists(normal_path)); | 176 EXPECT_TRUE(file_util::DirectoryExists(normal_path)); |
177 EXPECT_TRUE(file_util::DirectoryExists(session_only_path)); | 177 EXPECT_TRUE(file_util::DirectoryExists(session_only_path)); |
178 } | 178 } |
OLD | NEW |