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/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/indexed_db/indexed_db_connection.h" | 10 #include "content/browser/indexed_db/indexed_db_connection.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 webkit_database::GetIdentifierFromOrigin(kSessionOnlyOrigin)); | 67 webkit_database::GetIdentifierFromOrigin(kSessionOnlyOrigin)); |
68 ASSERT_TRUE(file_util::CreateDirectory(normal_path)); | 68 ASSERT_TRUE(file_util::CreateDirectory(normal_path)); |
69 ASSERT_TRUE(file_util::CreateDirectory(session_only_path)); | 69 ASSERT_TRUE(file_util::CreateDirectory(session_only_path)); |
70 FlushIndexedDBTaskRunner(); | 70 FlushIndexedDBTaskRunner(); |
71 message_loop_.RunUntilIdle(); | 71 message_loop_.RunUntilIdle(); |
72 } | 72 } |
73 | 73 |
74 FlushIndexedDBTaskRunner(); | 74 FlushIndexedDBTaskRunner(); |
75 message_loop_.RunUntilIdle(); | 75 message_loop_.RunUntilIdle(); |
76 | 76 |
77 EXPECT_TRUE(file_util::DirectoryExists(normal_path)); | 77 EXPECT_TRUE(base::DirectoryExists(normal_path)); |
78 EXPECT_FALSE(file_util::DirectoryExists(session_only_path)); | 78 EXPECT_FALSE(base::DirectoryExists(session_only_path)); |
79 } | 79 } |
80 | 80 |
81 TEST_F(IndexedDBTest, SetForceKeepSessionState) { | 81 TEST_F(IndexedDBTest, SetForceKeepSessionState) { |
82 base::ScopedTempDir temp_dir; | 82 base::ScopedTempDir temp_dir; |
83 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 83 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
84 | 84 |
85 base::FilePath normal_path; | 85 base::FilePath normal_path; |
86 base::FilePath session_only_path; | 86 base::FilePath session_only_path; |
87 | 87 |
88 // Create the scope which will ensure we run the destructor of the context. | 88 // Create the scope which will ensure we run the destructor of the context. |
(...skipping 12 matching lines...) Expand all Loading... |
101 webkit_database::GetIdentifierFromOrigin(kSessionOnlyOrigin)); | 101 webkit_database::GetIdentifierFromOrigin(kSessionOnlyOrigin)); |
102 ASSERT_TRUE(file_util::CreateDirectory(normal_path)); | 102 ASSERT_TRUE(file_util::CreateDirectory(normal_path)); |
103 ASSERT_TRUE(file_util::CreateDirectory(session_only_path)); | 103 ASSERT_TRUE(file_util::CreateDirectory(session_only_path)); |
104 message_loop_.RunUntilIdle(); | 104 message_loop_.RunUntilIdle(); |
105 } | 105 } |
106 | 106 |
107 // Make sure we wait until the destructor has run. | 107 // Make sure we wait until the destructor has run. |
108 message_loop_.RunUntilIdle(); | 108 message_loop_.RunUntilIdle(); |
109 | 109 |
110 // No data was cleared because of SetForceKeepSessionState. | 110 // No data was cleared because of SetForceKeepSessionState. |
111 EXPECT_TRUE(file_util::DirectoryExists(normal_path)); | 111 EXPECT_TRUE(base::DirectoryExists(normal_path)); |
112 EXPECT_TRUE(file_util::DirectoryExists(session_only_path)); | 112 EXPECT_TRUE(base::DirectoryExists(session_only_path)); |
113 } | 113 } |
114 | 114 |
115 class MockConnection : public IndexedDBConnection { | 115 class MockConnection : public IndexedDBConnection { |
116 public: | 116 public: |
117 explicit MockConnection(bool expect_force_close) | 117 explicit MockConnection(bool expect_force_close) |
118 : IndexedDBConnection(NULL, NULL), | 118 : IndexedDBConnection(NULL, NULL), |
119 expect_force_close_(expect_force_close), | 119 expect_force_close_(expect_force_close), |
120 force_close_called_(false) {} | 120 force_close_called_(false) {} |
121 | 121 |
122 virtual ~MockConnection() { | 122 virtual ~MockConnection() { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 FROM_HERE, | 180 FROM_HERE, |
181 base::Bind( | 181 base::Bind( |
182 &IndexedDBContextImpl::DeleteForOrigin, idb_context, kTestOrigin)); | 182 &IndexedDBContextImpl::DeleteForOrigin, idb_context, kTestOrigin)); |
183 FlushIndexedDBTaskRunner(); | 183 FlushIndexedDBTaskRunner(); |
184 message_loop_.RunUntilIdle(); | 184 message_loop_.RunUntilIdle(); |
185 } | 185 } |
186 | 186 |
187 // Make sure we wait until the destructor has run. | 187 // Make sure we wait until the destructor has run. |
188 message_loop_.RunUntilIdle(); | 188 message_loop_.RunUntilIdle(); |
189 | 189 |
190 EXPECT_FALSE(file_util::DirectoryExists(test_path)); | 190 EXPECT_FALSE(base::DirectoryExists(test_path)); |
191 } | 191 } |
192 | 192 |
193 } // namespace content | 193 } // namespace content |
OLD | NEW |