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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 virtual void SetUp() OVERRIDE { | 60 virtual void SetUp() OVERRIDE { |
61 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 61 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
62 profile_.reset(new util::MockProfile(temp_dir_.path())); | 62 profile_.reset(new util::MockProfile(temp_dir_.path())); |
63 ResetFrontend(); | 63 ResetFrontend(); |
64 } | 64 } |
65 | 65 |
66 virtual void TearDown() OVERRIDE { | 66 virtual void TearDown() OVERRIDE { |
67 frontend_.reset(); | 67 frontend_.reset(); |
68 profile_.reset(); | 68 profile_.reset(); |
69 // Execute any pending deletion tasks. | 69 // Execute any pending deletion tasks. |
70 message_loop_.RunAllPending(); | 70 message_loop_.RunUntilIdle(); |
71 } | 71 } |
72 | 72 |
73 protected: | 73 protected: |
74 void ResetFrontend() { | 74 void ResetFrontend() { |
75 storage_factory_->Reset(new LeveldbSettingsStorageFactory()); | 75 storage_factory_->Reset(new LeveldbSettingsStorageFactory()); |
76 frontend_.reset( | 76 frontend_.reset( |
77 SettingsFrontend::Create(storage_factory_.get(), profile_.get())); | 77 SettingsFrontend::Create(storage_factory_.get(), profile_.get())); |
78 } | 78 } |
79 | 79 |
80 base::ScopedTempDir temp_dir_; | 80 base::ScopedTempDir temp_dir_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 ValueStore* storage = util::GetStorage(id, frontend_.get()); | 131 ValueStore* storage = util::GetStorage(id, frontend_.get()); |
132 | 132 |
133 { | 133 { |
134 StringValue bar("bar"); | 134 StringValue bar("bar"); |
135 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); | 135 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); |
136 ASSERT_FALSE(result->HasError()); | 136 ASSERT_FALSE(result->HasError()); |
137 } | 137 } |
138 | 138 |
139 // This would be triggered by extension uninstall via a DataDeleter. | 139 // This would be triggered by extension uninstall via a DataDeleter. |
140 frontend_->DeleteStorageSoon(id); | 140 frontend_->DeleteStorageSoon(id); |
141 MessageLoop::current()->RunAllPending(); | 141 MessageLoop::current()->RunUntilIdle(); |
142 | 142 |
143 // The storage area may no longer be valid post-uninstall, so re-request. | 143 // The storage area may no longer be valid post-uninstall, so re-request. |
144 storage = util::GetStorage(id, frontend_.get()); | 144 storage = util::GetStorage(id, frontend_.get()); |
145 { | 145 { |
146 ValueStore::ReadResult result = storage->Get(); | 146 ValueStore::ReadResult result = storage->Get(); |
147 ASSERT_FALSE(result->HasError()); | 147 ASSERT_FALSE(result->HasError()); |
148 EXPECT_TRUE(result->settings()->empty()); | 148 EXPECT_TRUE(result->settings()->empty()); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
(...skipping 13 matching lines...) Expand all Loading... |
165 | 165 |
166 // Should need to both clear the database and delete the frontend for the | 166 // Should need to both clear the database and delete the frontend for the |
167 // leveldb database to be deleted from disk. | 167 // leveldb database to be deleted from disk. |
168 { | 168 { |
169 ValueStore::WriteResult result = storage->Clear(); | 169 ValueStore::WriteResult result = storage->Clear(); |
170 ASSERT_FALSE(result->HasError()); | 170 ASSERT_FALSE(result->HasError()); |
171 EXPECT_TRUE(file_util::PathExists(temp_dir_.path())); | 171 EXPECT_TRUE(file_util::PathExists(temp_dir_.path())); |
172 } | 172 } |
173 | 173 |
174 frontend_.reset(); | 174 frontend_.reset(); |
175 MessageLoop::current()->RunAllPending(); | 175 MessageLoop::current()->RunUntilIdle(); |
176 // TODO(kalman): Figure out why this fails, despite appearing to work. | 176 // TODO(kalman): Figure out why this fails, despite appearing to work. |
177 // Leaving this commented out rather than disabling the whole test so that the | 177 // Leaving this commented out rather than disabling the whole test so that the |
178 // deletion code paths are at least exercised. | 178 // deletion code paths are at least exercised. |
179 //EXPECT_FALSE(file_util::PathExists(temp_dir_.path())); | 179 //EXPECT_FALSE(file_util::PathExists(temp_dir_.path())); |
180 } | 180 } |
181 | 181 |
182 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
183 // Failing on vista dbg. http://crbug.com/111100, http://crbug.com/108724 | 183 // Failing on vista dbg. http://crbug.com/111100, http://crbug.com/108724 |
184 #define QuotaLimitsEnforcedCorrectlyForSyncAndLocal \ | 184 #define QuotaLimitsEnforcedCorrectlyForSyncAndLocal \ |
185 DISABLED_QuotaLimitsEnforcedCorrectlyForSyncAndLocal | 185 DISABLED_QuotaLimitsEnforcedCorrectlyForSyncAndLocal |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 std::set<std::string> permissions; | 265 std::set<std::string> permissions; |
266 permissions.insert("unlimitedStorage"); | 266 permissions.insert("unlimitedStorage"); |
267 profile_->GetMockExtensionService()->AddExtensionWithIdAndPermissions( | 267 profile_->GetMockExtensionService()->AddExtensionWithIdAndPermissions( |
268 id, Extension::TYPE_EXTENSION, permissions); | 268 id, Extension::TYPE_EXTENSION, permissions); |
269 | 269 |
270 frontend_->RunWithStorage( | 270 frontend_->RunWithStorage( |
271 id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); | 271 id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); |
272 frontend_->RunWithStorage( | 272 frontend_->RunWithStorage( |
273 id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); | 273 id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); |
274 | 274 |
275 MessageLoop::current()->RunAllPending(); | 275 MessageLoop::current()->RunUntilIdle(); |
276 } | 276 } |
277 | 277 |
278 } // namespace extensions | 278 } // namespace extensions |
OLD | NEW |