| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // be too rigorous. | 104 // be too rigorous. |
| 105 { | 105 { |
| 106 StringValue bar("bar"); | 106 StringValue bar("bar"); |
| 107 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); | 107 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); |
| 108 ASSERT_FALSE(result->HasError()); | 108 ASSERT_FALSE(result->HasError()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 { | 111 { |
| 112 ValueStore::ReadResult result = storage->Get(); | 112 ValueStore::ReadResult result = storage->Get(); |
| 113 ASSERT_FALSE(result->HasError()); | 113 ASSERT_FALSE(result->HasError()); |
| 114 EXPECT_FALSE(result->settings()->empty()); | 114 EXPECT_FALSE(result->settings().empty()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 ResetFrontend(); | 117 ResetFrontend(); |
| 118 storage = util::GetStorage(id, frontend_.get()); | 118 storage = util::GetStorage(id, frontend_.get()); |
| 119 | 119 |
| 120 { | 120 { |
| 121 ValueStore::ReadResult result = storage->Get(); | 121 ValueStore::ReadResult result = storage->Get(); |
| 122 ASSERT_FALSE(result->HasError()); | 122 ASSERT_FALSE(result->HasError()); |
| 123 EXPECT_FALSE(result->settings()->empty()); | 123 EXPECT_FALSE(result->settings().empty()); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 TEST_F(ExtensionSettingsFrontendTest, SettingsClearedOnUninstall) { | 127 TEST_F(ExtensionSettingsFrontendTest, SettingsClearedOnUninstall) { |
| 128 const std::string id = "ext"; | 128 const std::string id = "ext"; |
| 129 ExtensionServiceInterface* esi = | 129 ExtensionServiceInterface* esi = |
| 130 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 130 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
| 131 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> | 131 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> |
| 132 AddExtensionWithId(id, Manifest::TYPE_LEGACY_PACKAGED_APP); | 132 AddExtensionWithId(id, Manifest::TYPE_LEGACY_PACKAGED_APP); |
| 133 | 133 |
| 134 ValueStore* storage = util::GetStorage(id, frontend_.get()); | 134 ValueStore* storage = util::GetStorage(id, frontend_.get()); |
| 135 | 135 |
| 136 { | 136 { |
| 137 StringValue bar("bar"); | 137 StringValue bar("bar"); |
| 138 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); | 138 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); |
| 139 ASSERT_FALSE(result->HasError()); | 139 ASSERT_FALSE(result->HasError()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // This would be triggered by extension uninstall via a DataDeleter. | 142 // This would be triggered by extension uninstall via a DataDeleter. |
| 143 frontend_->DeleteStorageSoon(id); | 143 frontend_->DeleteStorageSoon(id); |
| 144 base::MessageLoop::current()->RunUntilIdle(); | 144 base::MessageLoop::current()->RunUntilIdle(); |
| 145 | 145 |
| 146 // The storage area may no longer be valid post-uninstall, so re-request. | 146 // The storage area may no longer be valid post-uninstall, so re-request. |
| 147 storage = util::GetStorage(id, frontend_.get()); | 147 storage = util::GetStorage(id, frontend_.get()); |
| 148 { | 148 { |
| 149 ValueStore::ReadResult result = storage->Get(); | 149 ValueStore::ReadResult result = storage->Get(); |
| 150 ASSERT_FALSE(result->HasError()); | 150 ASSERT_FALSE(result->HasError()); |
| 151 EXPECT_TRUE(result->settings()->empty()); | 151 EXPECT_TRUE(result->settings().empty()); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 TEST_F(ExtensionSettingsFrontendTest, LeveldbDatabaseDeletedFromDiskOnClear) { | 155 TEST_F(ExtensionSettingsFrontendTest, LeveldbDatabaseDeletedFromDiskOnClear) { |
| 156 const std::string id = "ext"; | 156 const std::string id = "ext"; |
| 157 ExtensionServiceInterface* esi = | 157 ExtensionServiceInterface* esi = |
| 158 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 158 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
| 159 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> | 159 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> |
| 160 AddExtensionWithId(id, Manifest::TYPE_EXTENSION); | 160 AddExtensionWithId(id, Manifest::TYPE_EXTENSION); |
| 161 | 161 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 frontend_->RunWithStorage( | 280 frontend_->RunWithStorage( |
| 281 id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); | 281 id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); |
| 282 frontend_->RunWithStorage( | 282 frontend_->RunWithStorage( |
| 283 id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); | 283 id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); |
| 284 | 284 |
| 285 base::MessageLoop::current()->RunUntilIdle(); | 285 base::MessageLoop::current()->RunUntilIdle(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace extensions | 288 } // namespace extensions |
| OLD | NEW |