1a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// found in the LICENSE file.
4a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
5a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ash/launcher/launcher.h"
6a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ash/launcher/launcher_view.h"
7a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ash/shell.h"
8a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/command_line.h"
9a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/message_loop/message_loop.h"
10a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/browser/lifetime/application_lifetime.h"
11a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/browser/ui/browser.h"
12a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/browser/ui/browser_list.h"
13a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/browser/ui/browser_window.h"
14a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/test/base/in_process_browser_test.h"
15a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ui/aura/root_window.h"
16a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ui/aura/test/event_generator.h"
17a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ui/base/test/ui_controls.h"
18a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ui/views/controls/menu/menu_controller.h"
19a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ui/views/view.h"
20a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "ui/views/view_model.h"
21a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
22a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)namespace {
23a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
24a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)class WindowSizerTest : public InProcessBrowserTest {
25a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) public:
26a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  WindowSizerTest() {}
27a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  virtual ~WindowSizerTest() {}
28a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
29a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
30a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    InProcessBrowserTest::SetUpCommandLine(command_line);
31a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    // Make screens sufficiently wide to host 2 browsers side by side.
32a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    command_line->AppendSwitchASCII("ash-host-window-bounds",
33a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)                                    "600x600,601+0-600x600");
34a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
35a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
36a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) private:
37a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(WindowSizerTest);
38a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)};
39a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
40a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)void CloseBrowser(Browser* browser) {
41a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  browser->window()->Close();
42a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  base::MessageLoop::current()->RunUntilIdle();
43a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
44a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
45a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)gfx::Rect GetChromeIconBoundsForRootWindow(aura::RootWindow* root_window) {
46a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  ash::Launcher* launcher = ash::Launcher::ForWindow(root_window);
47a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  const ash::internal::LauncherView* launcher_view =
48a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      launcher->GetLauncherViewForTest();
49a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  const views::ViewModel* view_model = launcher_view->view_model_for_test();
50a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
51a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(2, view_model->view_size());
52a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  return view_model->view_at(0)->GetBoundsInScreen();
53a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
54a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
55a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)void OpenBrowserUsingShelfOnRootWindow(aura::RootWindow* root_window) {
56a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  aura::test::EventGenerator generator(root_window);
57a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  gfx::Point center =
58a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      GetChromeIconBoundsForRootWindow(root_window).CenterPoint();
59a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  gfx::Display display =
60a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      ash::Shell::GetScreen()->GetDisplayNearestWindow(root_window);
61a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  const gfx::Point& origin = display.bounds().origin();
62a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  center.Offset(- origin.x(), - origin.y());
63a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  generator.MoveMouseTo(center);
64a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  generator.ClickLeftButton();
65a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
66a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
67a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}  // namespace
68a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
69a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#if defined(OS_WIN)
70a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#define MAYBE_OpenBrowserUsingShelfOnOhterDisplay DISABLED_OpenBrowserUsingShelfOnOhterDisplay
71a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#define MAYBE_OpenBrowserUsingContextMenuOnOhterDisplay DISABLED_OpenBrowserUsingContextMenuOnOhterDisplay
72a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#else
73a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#define MAYBE_OpenBrowserUsingShelfOnOhterDisplay OpenBrowserUsingShelfOnOhterDisplay
74a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#define MAYBE_OpenBrowserUsingContextMenuOnOhterDisplay OpenBrowserUsingContextMenuOnOhterDisplay
75a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#endif
76a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
77a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(WindowSizerTest,
78a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)                       MAYBE_OpenBrowserUsingShelfOnOhterDisplay) {
79a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Don't shutdown when closing the last browser window.
80a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  chrome::StartKeepAlive();
81a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
82a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  ash::Shell::RootWindowList root_windows = ash::Shell::GetAllRootWindows();
83a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
84a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  BrowserList* browser_list =
85a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
86a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
87a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(1u, browser_list->size());
88a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Close the browser window so that clicking icon will create a new window.
89a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  CloseBrowser(browser_list->get(0));
90a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(0u, browser_list->size());
91a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[0], ash::Shell::GetActiveRootWindow());
92a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
93a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  OpenBrowserUsingShelfOnRootWindow(root_windows[1]);
94a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
95a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // A new browser must be created on 2nd display.
96a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(1u, browser_list->size());
97a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[1],
98a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)            browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow());
99a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[1], ash::Shell::GetActiveRootWindow());
100a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
101a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Close the browser window so that clicking icon will create a new window.
102a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  CloseBrowser(browser_list->get(0));
103a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(0u, browser_list->size());
104a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
105a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  OpenBrowserUsingShelfOnRootWindow(root_windows[0]);
106a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
107a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // A new browser must be created on 1st display.
108a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(1u, browser_list->size());
109a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[0],
110a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)            browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow());
111a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[0], ash::Shell::GetActiveRootWindow());
112a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
113a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Balanced with the chrome::StartKeepAlive above.
114a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  chrome::EndKeepAlive();
115a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
116a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
117a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)namespace {
118a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
119a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)class WindowSizerContextMenuTest : public WindowSizerTest {
120a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) public:
121a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  WindowSizerContextMenuTest() {}
122a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  virtual ~WindowSizerContextMenuTest() {}
123a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
124a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  static void Step1(gfx::Point release_point) {
125a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    ui_controls::SendMouseEventsNotifyWhenDone(
126a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        ui_controls::RIGHT, ui_controls::DOWN,
127a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        base::Bind(&WindowSizerContextMenuTest::Step2, release_point));
128a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
129a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
130a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  static void Step2(gfx::Point release_point) {
131a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    ui_controls::SendMouseMoveNotifyWhenDone(
132a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        release_point.x(), release_point.y(),
133a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        base::Bind(&WindowSizerContextMenuTest::Step3));
134a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
135a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
136a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  static void Step3() {
137a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    ui_controls::SendMouseEventsNotifyWhenDone(
138a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        ui_controls::RIGHT, ui_controls::UP,
139a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        base::Bind(&WindowSizerContextMenuTest::QuitLoop));
140a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
141a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
142a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  static void QuitLoop() {
143a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    base::MessageLoop::current()->PostTask(
144a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        FROM_HERE,
145a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)        base::MessageLoop::QuitWhenIdleClosure());
146a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  }
147a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
148a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) private:
149a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(WindowSizerContextMenuTest);
150a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)};
151a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
152a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)void OpenBrowserUsingContextMenuOnRootWindow(aura::RootWindow* root_window) {
153a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  gfx::Point chrome_icon =
154a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      GetChromeIconBoundsForRootWindow(root_window).CenterPoint();
155a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  gfx::Point release_point = chrome_icon;
156a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  release_point.Offset(50, -120);
157a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  ui_controls::SendMouseMoveNotifyWhenDone(
158a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      chrome_icon.x(), chrome_icon.y(),
159a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      base::Bind(&WindowSizerContextMenuTest::Step1, release_point));
160a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  base::MessageLoop::current()->Run();
161a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
162a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
163a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}  // namespace
164a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
165a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(WindowSizerContextMenuTest,
166a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)                       MAYBE_OpenBrowserUsingContextMenuOnOhterDisplay) {
167a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Don't shutdown when closing the last browser window.
168a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  chrome::StartKeepAlive();
169a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
170a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  views::MenuController::TurnOffContextMenuSelectionHoldForTest();
171a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
172a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  ash::Shell::RootWindowList root_windows = ash::Shell::GetAllRootWindows();
173a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
174a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  BrowserList* browser_list =
175a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
176a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
177a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(1u, browser_list->size());
178a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[0], ash::Shell::GetActiveRootWindow());
179a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  CloseBrowser(browser_list->get(0));
180a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
181a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  OpenBrowserUsingContextMenuOnRootWindow(root_windows[1]);
182a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
183a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // A new browser must be created on 2nd display.
184a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(1u, browser_list->size());
185a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[1],
186a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)            browser_list->get(0)->window()->GetNativeWindow()->GetRootWindow());
187a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[1], ash::Shell::GetActiveRootWindow());
188a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
189a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  OpenBrowserUsingContextMenuOnRootWindow(root_windows[0]);
190a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
191a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Next new browser must be created on 1st display.
192a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(2u, browser_list->size());
193a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[0],
194a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)            browser_list->get(1)->window()->GetNativeWindow()->GetRootWindow());
195a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  EXPECT_EQ(root_windows[0], ash::Shell::GetActiveRootWindow());
196a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
197a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Balanced with the chrome::StartKeepAlive above.
198a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  chrome::EndKeepAlive();
199a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}
200