Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Unified Diff: chrome/browser/extensions/extension_settings_frontend_unittest.cc

Issue 8375047: Separate the syncing of extension settings and app settings into separate data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_settings_frontend_unittest.cc
diff --git a/chrome/browser/extensions/extension_settings_frontend_unittest.cc b/chrome/browser/extensions/extension_settings_frontend_unittest.cc
index d245850f4f14876bb6aa9cd98ca451896d2e4520..5da181ffa6200ebfe9087ca977609ba789c8babc 100644
--- a/chrome/browser/extensions/extension_settings_frontend_unittest.cc
+++ b/chrome/browser/extensions/extension_settings_frontend_unittest.cc
@@ -9,11 +9,12 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/scoped_temp_dir.h"
-#include "chrome/browser/extensions/extension_settings_backend.h"
#include "chrome/browser/extensions/extension_settings_frontend.h"
#include "chrome/browser/extensions/extension_settings_storage.h"
+#include "chrome/browser/extensions/extension_settings_test_util.h"
#include "chrome/common/chrome_notification_types.h"
-#include "chrome/test/base/testing_profile.h"
+
+using namespace extension_settings_test_util;
class ExtensionSettingsFrontendTest : public testing::Test {
public:
@@ -23,7 +24,7 @@ class ExtensionSettingsFrontendTest : public testing::Test {
virtual void SetUp() OVERRIDE {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- profile_.reset(new TestingProfile(temp_dir_.path()));
+ profile_.reset(new MockProfile(temp_dir_.path()));
frontend_.reset(new ExtensionSettingsFrontend(profile_.get()));
}
@@ -33,39 +34,25 @@ class ExtensionSettingsFrontendTest : public testing::Test {
}
protected:
- // Puts the settings backend in |backend|.
- void GetBackend(ExtensionSettingsBackend** backend) {
- frontend_->RunWithBackend(
- base::Bind(
- &ExtensionSettingsFrontendTest::AssignBackend,
- base::Unretained(this),
- backend));
- MessageLoop::current()->RunAllPending();
- ASSERT_TRUE(*backend);
- }
-
ScopedTempDir temp_dir_;
- scoped_ptr<TestingProfile> profile_;
+ scoped_ptr<MockProfile> profile_;
scoped_ptr<ExtensionSettingsFrontend> frontend_;
private:
- // Intended as a ExtensionSettingsFrontend::BackendCallback from GetBackend.
- void AssignBackend(
- ExtensionSettingsBackend** dst, ExtensionSettingsBackend* src) {
- *dst = src;
- }
-
MessageLoop message_loop_;
BrowserThread ui_thread_;
BrowserThread file_thread_;
};
-TEST_F(ExtensionSettingsFrontendTest, SettingsPreservedAcrossReconstruction) {
- ExtensionSettingsBackend* backend;
- GetBackend(&backend);
+// Get a semblance of coverage for both extension and app settings by
+// alternating in each test.
+// TODO(kalman): explicitly test the two interact correctly.
akalin 2011/10/28 06:04:54 consider parametrized tests here, too (Although I
not at google - send to devlin 2011/10/31 00:02:23 Ditto my last comment. I have a few things I need
+TEST_F(ExtensionSettingsFrontendTest, SettingsPreservedAcrossReconstruction) {
const std::string id = "ext";
- ExtensionSettingsStorage* storage = backend->GetStorage(id);
+ profile_->GetMockExtensionService()->AddExtension(id, false);
+
+ ExtensionSettingsStorage* storage = GetStorage(id, frontend_.get());
// The correctness of Get/Set/Remove/Clear is tested elsewhere so no need to
// be too rigorous.
@@ -78,8 +65,7 @@ TEST_F(ExtensionSettingsFrontendTest, SettingsPreservedAcrossReconstruction) {
EXPECT_FALSE(result.GetSettings()->empty());
frontend_.reset(new ExtensionSettingsFrontend(profile_.get()));
- GetBackend(&backend);
- storage = backend->GetStorage(id);
+ storage = GetStorage(id, frontend_.get());
result = storage->Get();
ASSERT_FALSE(result.HasError());
@@ -87,32 +73,31 @@ TEST_F(ExtensionSettingsFrontendTest, SettingsPreservedAcrossReconstruction) {
}
TEST_F(ExtensionSettingsFrontendTest, SettingsClearedOnUninstall) {
- ExtensionSettingsBackend* backend;
- GetBackend(&backend);
-
const std::string id = "ext";
- ExtensionSettingsStorage* storage = backend->GetStorage(id);
+ profile_->GetMockExtensionService()->AddExtension(id, true);
+
+ ExtensionSettingsStorage* storage = GetStorage(id, frontend_.get());
StringValue bar("bar");
ExtensionSettingsStorage::Result result = storage->Set("foo", bar);
ASSERT_FALSE(result.HasError());
// This would be triggered by extension uninstall via an ExtensionDataDeleter.
- backend->DeleteExtensionData(id);
+ frontend_->DeleteStorageSoon(id);
+ MessageLoop::current()->RunAllPending();
// The storage area may no longer be valid post-uninstall, so re-request.
- storage = backend->GetStorage(id);
+ storage = GetStorage(id, frontend_.get());
result = storage->Get();
ASSERT_FALSE(result.HasError());
EXPECT_TRUE(result.GetSettings()->empty());
}
TEST_F(ExtensionSettingsFrontendTest, LeveldbDatabaseDeletedFromDiskOnClear) {
- ExtensionSettingsBackend* backend;
- GetBackend(&backend);
-
const std::string id = "ext";
- ExtensionSettingsStorage* storage = backend->GetStorage(id);
+ profile_->GetMockExtensionService()->AddExtension(id, false);
+
+ ExtensionSettingsStorage* storage = GetStorage(id, frontend_.get());
StringValue bar("bar");
ExtensionSettingsStorage::Result result = storage->Set("foo", bar);

Powered by Google App Engine
This is Rietveld 408576698