| 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.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory
.h" | 11 #include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory
.h" |
| 12 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 12 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
| 13 #include "chrome/browser/extensions/api/storage/settings_namespace.h" | 13 #include "chrome/browser/extensions/api/storage/settings_namespace.h" |
| 14 #include "chrome/browser/extensions/api/storage/settings_test_util.h" | 14 #include "chrome/browser/extensions/api/storage/settings_test_util.h" |
| 15 #include "chrome/browser/value_store/value_store.h" | 15 #include "chrome/browser/value_store/value_store.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/extensions/extension_unittest.h" | |
| 18 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 19 |
| 21 using content::BrowserThread; | 20 using content::BrowserThread; |
| 22 | 21 |
| 23 namespace extensions { | 22 namespace extensions { |
| 24 | 23 |
| 25 namespace settings = settings_namespace; | 24 namespace settings = settings_namespace; |
| 26 namespace util = settings_test_util; | 25 namespace util = settings_test_util; |
| 27 | 26 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 43 scoped_ptr<Value> CreateMegabyte() { | 42 scoped_ptr<Value> CreateMegabyte() { |
| 44 ListValue* megabyte = new ListValue(); | 43 ListValue* megabyte = new ListValue(); |
| 45 for (int i = 0; i < 1000; ++i) { | 44 for (int i = 0; i < 1000; ++i) { |
| 46 megabyte->Append(CreateKilobyte().release()); | 45 megabyte->Append(CreateKilobyte().release()); |
| 47 } | 46 } |
| 48 return scoped_ptr<Value>(megabyte); | 47 return scoped_ptr<Value>(megabyte); |
| 49 } | 48 } |
| 50 | 49 |
| 51 } | 50 } |
| 52 | 51 |
| 53 class ExtensionSettingsFrontendTest : public ExtensionTest { | 52 class ExtensionSettingsFrontendTest : public testing::Test { |
| 54 public: | 53 public: |
| 55 ExtensionSettingsFrontendTest() | 54 ExtensionSettingsFrontendTest() |
| 56 : storage_factory_(new util::ScopedSettingsStorageFactory()), | 55 : storage_factory_(new util::ScopedSettingsStorageFactory()), |
| 57 ui_thread_(BrowserThread::UI, MessageLoop::current()), | 56 ui_thread_(BrowserThread::UI, MessageLoop::current()), |
| 58 file_thread_(BrowserThread::FILE, MessageLoop::current()) {} | 57 file_thread_(BrowserThread::FILE, MessageLoop::current()) {} |
| 59 | 58 |
| 60 virtual void SetUp() OVERRIDE { | 59 virtual void SetUp() OVERRIDE { |
| 61 ExtensionTest::SetUp(); | |
| 62 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 60 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 63 profile_.reset(new util::MockProfile(temp_dir_.path())); | 61 profile_.reset(new util::MockProfile(temp_dir_.path())); |
| 64 ResetFrontend(); | 62 ResetFrontend(); |
| 65 } | 63 } |
| 66 | 64 |
| 67 virtual void TearDown() OVERRIDE { | 65 virtual void TearDown() OVERRIDE { |
| 68 frontend_.reset(); | 66 frontend_.reset(); |
| 69 profile_.reset(); | 67 profile_.reset(); |
| 70 // Execute any pending deletion tasks. | 68 // Execute any pending deletion tasks. |
| 71 message_loop_.RunUntilIdle(); | 69 message_loop_.RunUntilIdle(); |
| 72 ExtensionTest::TearDown(); | |
| 73 } | 70 } |
| 74 | 71 |
| 75 protected: | 72 protected: |
| 76 void ResetFrontend() { | 73 void ResetFrontend() { |
| 77 storage_factory_->Reset(new LeveldbSettingsStorageFactory()); | 74 storage_factory_->Reset(new LeveldbSettingsStorageFactory()); |
| 78 frontend_.reset( | 75 frontend_.reset( |
| 79 SettingsFrontend::Create(storage_factory_.get(), profile_.get())); | 76 SettingsFrontend::Create(storage_factory_.get(), profile_.get())); |
| 80 } | 77 } |
| 81 | 78 |
| 82 base::ScopedTempDir temp_dir_; | 79 base::ScopedTempDir temp_dir_; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 279 |
| 283 frontend_->RunWithStorage( | 280 frontend_->RunWithStorage( |
| 284 id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); | 281 id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); |
| 285 frontend_->RunWithStorage( | 282 frontend_->RunWithStorage( |
| 286 id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); | 283 id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); |
| 287 | 284 |
| 288 MessageLoop::current()->RunUntilIdle(); | 285 MessageLoop::current()->RunUntilIdle(); |
| 289 } | 286 } |
| 290 | 287 |
| 291 } // namespace extensions | 288 } // namespace extensions |
| OLD | NEW |