Commit 62e03626 authored by limasdf@gmail.com's avatar limasdf@gmail.com

Add ExtensionsTestBrowserContext class for test.

and Use ExtensionTestBrowserContext for ImageLoader unittest.

ExtensionsTestBrowserContext class does 
set TestExtensionsBrowserClient from constructor and
call DestroyBrowserContextServices from destructor.

ExtensionTestBrowserContext will be used instead of TestingProfile.

R=yoz@chromium.org, rdevlin@chromium.org
BUG=354046
TEST=unit_tests --gtest_filter=ImageLoaderTest.DeleteExtensionWhileWaitingForCache

Review URL: https://codereview.chromium.org/355223002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284330 0039d316-1c4b-4281-b951-d872f2087c98
parent cf8cd3d1
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
'../components/components.gyp:sync_driver_test_support', '../components/components.gyp:sync_driver_test_support',
'../content/content.gyp:content_app_both', '../content/content.gyp:content_app_both',
'../content/content_shell_and_tests.gyp:test_support_content', '../content/content_shell_and_tests.gyp:test_support_content',
'../extensions/extensions.gyp:extensions_test_support',
'../net/net.gyp:net', '../net/net.gyp:net',
'../net/net.gyp:net_test_support', '../net/net.gyp:net_test_support',
'../skia/skia.gyp:skia', '../skia/skia.gyp:skia',
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "extensions/browser/extensions_test_browser_context.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/test_extensions_browser_client.h"
namespace extensions {
ExtensionsTestBrowserContext::ExtensionsTestBrowserContext() :
extensions_browser_client_(this) {
BrowserContextDependencyManager::GetInstance()
->CreateBrowserContextServicesForTest(this);
ExtensionsBrowserClient::Set(&extensions_browser_client_);
}
ExtensionsTestBrowserContext::~ExtensionsTestBrowserContext() {
BrowserContextDependencyManager::GetInstance()
->DestroyBrowserContextServices(this);
ExtensionsBrowserClient::Set(NULL);
}
} // namespace extensions
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_COMMON_EXTENSIONS_TEST_BROWSER_CONTEXT_H_
#define EXTENSIONS_COMMON_EXTENSIONS_TEST_BROWSER_CONTEXT_H_
#include "content/public/test/test_browser_context.h"
#include "extensions/browser/test_extensions_browser_client.h"
namespace extensions {
// An implementation of BrowserContext used for extension testing. It will set
// necessary extension state like the ExtensionsBrowserClient and any keyed
// services, and cleans up after itself on destruction.
class ExtensionsTestBrowserContext : public content::TestBrowserContext {
public:
ExtensionsTestBrowserContext();
virtual ~ExtensionsTestBrowserContext();
private:
TestExtensionsBrowserClient extensions_browser_client_;
DISALLOW_COPY_AND_ASSIGN(ExtensionsTestBrowserContext);
};
} // namespace extensions
#endif // EXTENSIONS_COMMON_EXTENSIONS_TEST_BROWSER_CONTEXT_H_
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread.h"
#include "extensions/browser/component_extension_resource_manager.h" #include "extensions/browser/component_extension_resource_manager.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extensions_browser_client.h" #include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/extensions_test_browser_context.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_icon_set.h" #include "extensions/common/extension_icon_set.h"
...@@ -185,13 +185,10 @@ TEST_F(ImageLoaderTest, DeleteExtensionWhileWaitingForCache) { ...@@ -185,13 +185,10 @@ TEST_F(ImageLoaderTest, DeleteExtensionWhileWaitingForCache) {
// The image isn't cached, so we should not have received notification. // The image isn't cached, so we should not have received notification.
EXPECT_EQ(0, image_loaded_count()); EXPECT_EQ(0, image_loaded_count());
extensions::ExtensionsTestBrowserContext browser_context;
// Send out notification the extension was uninstalled. // Send out notification the extension was uninstalled.
UnloadedExtensionInfo details(extension.get(), extensions::ExtensionRegistry::Get(&browser_context)->TriggerOnUnloaded(
UnloadedExtensionInfo::REASON_UNINSTALL); extension.get(), UnloadedExtensionInfo::REASON_UNINSTALL);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
content::NotificationService::AllSources(),
content::Details<UnloadedExtensionInfo>(&details));
// Chuck the extension, that way if anyone tries to access it we should crash // Chuck the extension, that way if anyone tries to access it we should crash
// or get valgrind errors. // or get valgrind errors.
......
...@@ -660,6 +660,8 @@ ...@@ -660,6 +660,8 @@
'<(SHARED_INTERMEDIATE_DIR)', '<(SHARED_INTERMEDIATE_DIR)',
], ],
'sources': [ 'sources': [
'browser/extensions_test_browser_context.cc',
'browser/extensions_test_browser_context.h',
'browser/test_extensions_browser_client.cc', 'browser/test_extensions_browser_client.cc',
'browser/test_extensions_browser_client.h', 'browser/test_extensions_browser_client.h',
'browser/test_management_policy.cc', 'browser/test_management_policy.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment