| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/storage/storage_frontend.h" | 5 #include "extensions/browser/api/storage/storage_frontend.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // history, the test names are unchanged. | 42 // history, the test names are unchanged. |
| 43 class ExtensionSettingsFrontendTest : public ExtensionsTest { | 43 class ExtensionSettingsFrontendTest : public ExtensionsTest { |
| 44 public: | 44 public: |
| 45 ExtensionSettingsFrontendTest() | 45 ExtensionSettingsFrontendTest() |
| 46 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), | 46 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), |
| 47 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {} | 47 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) {} |
| 48 | 48 |
| 49 void SetUp() override { | 49 void SetUp() override { |
| 50 ExtensionsTest::SetUp(); | 50 ExtensionsTest::SetUp(); |
| 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 52 storage_factory_ = new ValueStoreFactoryImpl(temp_dir_.path()); | 52 storage_factory_ = new ValueStoreFactoryImpl(temp_dir_.GetPath()); |
| 53 ResetFrontend(); | 53 ResetFrontend(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void TearDown() override { | 56 void TearDown() override { |
| 57 frontend_.reset(); | 57 frontend_.reset(); |
| 58 // Execute any pending deletion tasks. | 58 // Execute any pending deletion tasks. |
| 59 base::RunLoop().RunUntilIdle(); | 59 base::RunLoop().RunUntilIdle(); |
| 60 ExtensionsTest::TearDown(); | 60 ExtensionsTest::TearDown(); |
| 61 } | 61 } |
| 62 | 62 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 scoped_refptr<const Extension> extension = | 156 scoped_refptr<const Extension> extension = |
| 157 util::AddExtensionWithId(browser_context(), id, Manifest::TYPE_EXTENSION); | 157 util::AddExtensionWithId(browser_context(), id, Manifest::TYPE_EXTENSION); |
| 158 | 158 |
| 159 ValueStore* storage = | 159 ValueStore* storage = |
| 160 util::GetStorage(extension, settings::LOCAL, frontend_.get()); | 160 util::GetStorage(extension, settings::LOCAL, frontend_.get()); |
| 161 | 161 |
| 162 { | 162 { |
| 163 base::StringValue bar("bar"); | 163 base::StringValue bar("bar"); |
| 164 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); | 164 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); |
| 165 ASSERT_TRUE(result->status().ok()); | 165 ASSERT_TRUE(result->status().ok()); |
| 166 EXPECT_TRUE(base::PathExists(temp_dir_.path())); | 166 EXPECT_TRUE(base::PathExists(temp_dir_.GetPath())); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Should need to both clear the database and delete the frontend for the | 169 // Should need to both clear the database and delete the frontend for the |
| 170 // leveldb database to be deleted from disk. | 170 // leveldb database to be deleted from disk. |
| 171 { | 171 { |
| 172 ValueStore::WriteResult result = storage->Clear(); | 172 ValueStore::WriteResult result = storage->Clear(); |
| 173 ASSERT_TRUE(result->status().ok()); | 173 ASSERT_TRUE(result->status().ok()); |
| 174 EXPECT_TRUE(base::PathExists(temp_dir_.path())); | 174 EXPECT_TRUE(base::PathExists(temp_dir_.GetPath())); |
| 175 } | 175 } |
| 176 | 176 |
| 177 frontend_.reset(); | 177 frontend_.reset(); |
| 178 base::RunLoop().RunUntilIdle(); | 178 base::RunLoop().RunUntilIdle(); |
| 179 // TODO(kalman): Figure out why this fails, despite appearing to work. | 179 // TODO(kalman): Figure out why this fails, despite appearing to work. |
| 180 // Leaving this commented out rather than disabling the whole test so that the | 180 // Leaving this commented out rather than disabling the whole test so that the |
| 181 // deletion code paths are at least exercised. | 181 // deletion code paths are at least exercised. |
| 182 //EXPECT_FALSE(base::PathExists(temp_dir_.path())); | 182 // EXPECT_FALSE(base::PathExists(temp_dir_.GetPath())); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Disabled (slow), http://crbug.com/322751 . | 185 // Disabled (slow), http://crbug.com/322751 . |
| 186 TEST_F(ExtensionSettingsFrontendTest, | 186 TEST_F(ExtensionSettingsFrontendTest, |
| 187 DISABLED_QuotaLimitsEnforcedCorrectlyForSyncAndLocal) { | 187 DISABLED_QuotaLimitsEnforcedCorrectlyForSyncAndLocal) { |
| 188 const std::string id = "ext"; | 188 const std::string id = "ext"; |
| 189 scoped_refptr<const Extension> extension = | 189 scoped_refptr<const Extension> extension = |
| 190 util::AddExtensionWithId(browser_context(), id, Manifest::TYPE_EXTENSION); | 190 util::AddExtensionWithId(browser_context(), id, Manifest::TYPE_EXTENSION); |
| 191 | 191 |
| 192 ValueStore* sync_storage = | 192 ValueStore* sync_storage = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 215 std::unique_ptr<base::Value> megabyte = util::CreateMegabyte(); | 215 std::unique_ptr<base::Value> megabyte = util::CreateMegabyte(); |
| 216 for (int i = 0; i < 5; ++i) { | 216 for (int i = 0; i < 5; ++i) { |
| 217 local_storage->Set(DEFAULTS, base::IntToString(i), *megabyte); | 217 local_storage->Set(DEFAULTS, base::IntToString(i), *megabyte); |
| 218 } | 218 } |
| 219 | 219 |
| 220 EXPECT_FALSE( | 220 EXPECT_FALSE( |
| 221 local_storage->Set(DEFAULTS, "WillError", *megabyte)->status().ok()); | 221 local_storage->Set(DEFAULTS, "WillError", *megabyte)->status().ok()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace extensions | 224 } // namespace extensions |
| OLD | NEW |