#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/common/page_transition_types.h"
#include "content/public/test/test_renderer_host.h"
+#include "ui/base/page_transition_types.h"
#if defined(USE_AURA)
#include "ui/aura/test/aura_test_helper.h"
+#include "ui/compositor/compositor.h"
+#include "ui/compositor/test/context_factories_for_test.h"
+#include "ui/wm/core/default_activation_client.h"
#endif
#if defined(USE_ASH)
#include "ash/test/ash_test_helper.h"
+#include "ash/test/ash_test_views_delegate.h"
#endif
#if defined(TOOLKIT_VIEWS)
+#include "chrome/browser/ui/views/chrome_constrained_window_views_client.h"
+#include "components/constrained_window/constrained_window_views.h"
#include "ui/views/test/test_views_delegate.h"
#endif
using content::NavigationController;
-using content::RenderViewHost;
-using content::RenderViewHostTester;
+using content::RenderFrameHost;
+using content::RenderFrameHostTester;
using content::WebContents;
BrowserWithTestWindowTest::BrowserWithTestWindowTest()
#if defined(OS_CHROMEOS)
// TODO(jamescook): Windows Ash support. This will require refactoring
// AshTestHelper and AuraTestHelper so they can be used at the same time,
- // perhaps by AshTestHelper owning an AuraTestHelper.
+ // perhaps by AshTestHelper owning an AuraTestHelper. Also, need to cleanup
+ // CreateViewsDelegate() below when cleanup done.
ash_test_helper_.reset(new ash::test::AshTestHelper(
base::MessageLoopForUI::current()));
ash_test_helper_->SetUp(true);
#elif defined(USE_AURA)
+ // The ContextFactory must exist before any Compositors are created.
+ bool enable_pixel_output = false;
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
+
aura_test_helper_.reset(new aura::test::AuraTestHelper(
base::MessageLoopForUI::current()));
- bool allow_test_contexts = true;
- aura_test_helper_->SetUp(allow_test_contexts);
+ aura_test_helper_->SetUp(context_factory);
+ new wm::DefaultActivationClient(aura_test_helper_->root_window());
#endif // USE_AURA
+
#if defined(TOOLKIT_VIEWS)
+#if !defined(OS_CHROMEOS)
views_delegate_.reset(CreateViewsDelegate());
- views::ViewsDelegate::views_delegate = views_delegate_.get();
-#endif
+#endif // !OS_CHROMEOS
+ SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient());
+#endif // TOOLKIT_VIEWS
// Subclasses can provide their own Profile.
profile_ = CreateProfile();
ash_test_helper_->TearDown();
#elif defined(USE_AURA)
aura_test_helper_->TearDown();
+ ui::TerminateContextFactoryForTests();
#endif
testing::Test::TearDown();
base::MessageLoop::current()->Run();
#if defined(TOOLKIT_VIEWS)
- views::ViewsDelegate::views_delegate = NULL;
+ SetConstrainedWindowViewsClient(scoped_ptr<ConstrainedWindowViewsClient>());
views_delegate_.reset(NULL);
#endif
}
void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) {
- chrome::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED);
+ chrome::NavigateParams params(browser, url, ui::PAGE_TRANSITION_TYPED);
params.tabstrip_index = 0;
params.disposition = NEW_FOREGROUND_TAB;
chrome::Navigate(¶ms);
if (!controller->GetPendingEntry())
return; // Nothing to commit.
- RenderViewHost* old_rvh =
- controller->GetWebContents()->GetRenderViewHost();
+ RenderFrameHost* old_rfh = controller->GetWebContents()->GetMainFrame();
- RenderViewHost* pending_rvh = RenderViewHostTester::GetPendingForController(
+ RenderFrameHost* pending_rfh = RenderFrameHostTester::GetPendingForController(
controller);
- if (pending_rvh) {
- // Simulate the ShouldClose_ACK that is received from the current renderer
+ if (pending_rfh) {
+ // Simulate the BeforeUnload_ACK that is received from the current renderer
// for a cross-site navigation.
- DCHECK_NE(old_rvh, pending_rvh);
- RenderViewHostTester::For(old_rvh)->SendShouldCloseACK(true);
+ DCHECK_NE(old_rfh, pending_rfh);
+ RenderFrameHostTester::For(old_rfh)->SendBeforeUnloadACK(true);
}
- // Commit on the pending_rvh, if one exists.
- RenderViewHost* test_rvh = pending_rvh ? pending_rvh : old_rvh;
- RenderViewHostTester* test_rvh_tester = RenderViewHostTester::For(test_rvh);
+ // Commit on the pending_rfh, if one exists.
+ RenderFrameHost* test_rfh = pending_rfh ? pending_rfh : old_rfh;
+ RenderFrameHostTester* test_rfh_tester = RenderFrameHostTester::For(test_rfh);
// Simulate a SwapOut_ACK before the navigation commits.
- if (pending_rvh)
- RenderViewHostTester::For(old_rvh)->SimulateSwapOutACK();
+ if (pending_rfh)
+ RenderFrameHostTester::For(old_rfh)->SimulateSwapOutACK();
// For new navigations, we need to send a larger page ID. For renavigations,
// we need to send the preexisting page ID. We can tell these apart because
// renavigations will have a pending_entry_index while new ones won't (they'll
// just have a standalong pending_entry that isn't in the list already).
if (controller->GetPendingEntryIndex() >= 0) {
- test_rvh_tester->SendNavigateWithTransition(
+ test_rfh_tester->SendNavigateWithTransition(
controller->GetPendingEntry()->GetPageID(),
controller->GetPendingEntry()->GetURL(),
controller->GetPendingEntry()->GetTransitionType());
} else {
- test_rvh_tester->SendNavigateWithTransition(
- controller->GetWebContents()->
- GetMaxPageIDForSiteInstance(test_rvh->GetSiteInstance()) + 1,
+ test_rfh_tester->SendNavigateWithTransition(
+ controller->GetWebContents()->GetMaxPageIDForSiteInstance(
+ test_rfh->GetSiteInstance()) + 1,
controller->GetPendingEntry()->GetURL(),
controller->GetPendingEntry()->GetTransitionType());
}
NavigationController* controller,
const GURL& url) {
controller->LoadURL(
- url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string());
+ url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
CommitPendingLoad(controller);
}
chrome::HostDesktopType host_desktop_type,
BrowserWindow* browser_window) {
Browser::CreateParams params(profile, host_desktop_type);
- params.type = browser_type;
+ if (hosted_app) {
+ params = Browser::CreateParams::CreateForApp("Test",
+ true /* trusted_source */,
+ gfx::Rect(),
+ profile,
+ host_desktop_type);
+ } else {
+ params.type = browser_type;
+ }
params.window = browser_window;
- if (hosted_app)
- params.app_name = "Test";
return new Browser(params);
}
-#if defined(TOOLKIT_VIEWS)
+#if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS)
views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() {
+#if defined(USE_ASH)
+ return new ash::test::AshTestViewsDelegate;
+#else
return new views::TestViewsDelegate;
+#endif
}
#endif