This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/extensions/extension_view_host_factory.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_view_host.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/ui_test_utils.h"
#include "extensions/common/view_type.h"
namespace extensions {
typedef ExtensionBrowserTest ExtensionViewHostFactoryTest;
IN_PROC_BROWSER_TEST_F(ExtensionViewHostFactoryTest, CreateExtensionHosts) {
scoped_refptr<const Extension> extension =
LoadExtension(test_data_dir_.AppendASCII("api_test")
.AppendASCII("browser_action")
.AppendASCII("none"));
ASSERT_TRUE(extension.get());
content::BrowserContext* browser_context = browser()->profile();
{
scoped_ptr<ExtensionViewHost> host(
ExtensionViewHostFactory::CreatePopupHost(extension->url(), browser()));
EXPECT_EQ(extension.get(), host->extension());
EXPECT_EQ(browser_context, host->browser_context());
EXPECT_EQ(VIEW_TYPE_EXTENSION_POPUP, host->extension_host_type());
EXPECT_TRUE(host->view());
}
{
scoped_ptr<ExtensionViewHost> host(
ExtensionViewHostFactory::CreateInfobarHost(extension->url(),
browser()));
EXPECT_EQ(extension.get(), host->extension());
EXPECT_EQ(browser_context, host->browser_context());
EXPECT_EQ(VIEW_TYPE_EXTENSION_INFOBAR, host->extension_host_type());
EXPECT_TRUE(host->view());
}
{
scoped_ptr<ExtensionViewHost> host(
ExtensionViewHostFactory::CreateDialogHost(extension->url(),
browser()->profile()));
EXPECT_EQ(extension.get(), host->extension());
EXPECT_EQ(browser_context, host->browser_context());
EXPECT_EQ(VIEW_TYPE_EXTENSION_DIALOG, host->extension_host_type());
EXPECT_TRUE(host->view());
}
}
IN_PROC_BROWSER_TEST_F(ExtensionViewHostFactoryTest,
DISABLED_IncognitoExtensionHosts) {
Browser* incognito_browser = ui_test_utils::OpenURLOffTheRecord(
browser()->profile(), GURL("about:blank"));
scoped_refptr<const Extension> regular_extension =
LoadExtensionIncognito(test_data_dir_.AppendASCII("api_test")
.AppendASCII("browser_action")
.AppendASCII("none"));
ASSERT_TRUE(regular_extension.get());
scoped_ptr<ExtensionHost> regular_host(
ExtensionViewHostFactory::CreatePopupHost(
regular_extension->url(), incognito_browser));
content::BrowserContext* browser_context = browser()->profile();
EXPECT_EQ(browser_context, regular_host->browser_context());
scoped_refptr<const Extension> split_mode_extension =
LoadExtensionIncognito(test_data_dir_.AppendASCII("api_test")
.AppendASCII("browser_action")
.AppendASCII("split_mode"));
ASSERT_TRUE(split_mode_extension.get());
scoped_ptr<ExtensionHost> split_mode_host(
ExtensionViewHostFactory::CreatePopupHost(
split_mode_extension->url(), incognito_browser));
content::BrowserContext* incognito_context = incognito_browser->profile();
EXPECT_EQ(incognito_context, split_mode_host->browser_context());
}
}