Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / window_sizer / window_sizer_ash_unittest.cc
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
3 // found in the LICENSE file.
4
5 #include "ash/scoped_target_root_window.h"
6 #include "ash/screen_util.h"
7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h"
9 #include "ash/test/test_shell_delegate.h"
10 #include "ash/wm/window_positioner.h"
11 #include "ash/wm/window_resizer.h"
12 #include "ash/wm/window_state.h"
13 #include "base/compiler_specific.h"
14 #include "chrome/browser/ui/ash/ash_util.h"
15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h"
17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/test/base/testing_profile.h"
19 #include "content/public/test/render_view_test.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/aura/client/aura_constants.h"
22 #include "ui/aura/env.h"
23 #include "ui/aura/test/test_windows.h"
24 #include "ui/aura/window_event_dispatcher.h"
25 #include "ui/gfx/screen.h"
26 #include "ui/wm/public/activation_client.h"
27
28 typedef ash::test::AshTestBase WindowSizerAshTest;
29
30 namespace {
31
32 // A browser window proxy which is able to associate an aura native window with
33 // it.
34 class TestBrowserWindowAura : public TestBrowserWindow {
35  public:
36   // |native_window| will still be owned by the caller after the constructor
37   // was called.
38   explicit TestBrowserWindowAura(aura::Window* native_window)
39       : native_window_(native_window) {
40   }
41   ~TestBrowserWindowAura() override {}
42
43   // TestBrowserWindow overrides:
44   void Show() override {
45     native_window_->Show();
46     Activate();
47   }
48   void Hide() override { native_window_->Hide(); }
49   void Activate() override {
50     aura::client::GetActivationClient(
51         native_window_->GetRootWindow())->ActivateWindow(native_window_.get());
52   }
53   gfx::NativeWindow GetNativeWindow() const override {
54     return native_window_.get();
55   }
56   gfx::Rect GetBounds() const override { return native_window_->bounds(); }
57
58   Browser* browser() { return browser_.get(); }
59
60   void CreateBrowser(const Browser::CreateParams& params) {
61     Browser::CreateParams create_params = params;
62     create_params.window = this;
63     browser_.reset(new Browser(create_params));
64     if (browser_->is_type_tabbed() || browser_->is_app()) {
65       ash::wm::GetWindowState(native_window_.get())->
66           set_window_position_managed(true);
67     }
68   }
69
70  private:
71   scoped_ptr<Browser> browser_;
72   scoped_ptr<aura::Window> native_window_;
73
74   DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura);
75 };
76
77 scoped_ptr<TestBrowserWindowAura> CreateTestBrowserWindow(
78     aura::Window* window,
79     const gfx::Rect& bounds,
80     const Browser::CreateParams& params) {
81   if (!bounds.IsEmpty())
82     window->SetBounds(bounds);
83   scoped_ptr<TestBrowserWindowAura> browser_window(
84       new TestBrowserWindowAura(window));
85   browser_window->CreateBrowser(params);
86   return browser_window.Pass();
87 }
88
89 }  // namespace
90
91 // On desktop linux aura, we currently don't use the ash frame, breaking some
92 // tests which expect ash sizes: http://crbug.com/303862
93 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
94 #define MAYBE_DefaultSizeCase DISABLED_DefaultSizeCase
95 #else
96 #define MAYBE_DefaultSizeCase DefaultSizeCase
97 #endif
98
99 // Test that the window is sized appropriately for the first run experience
100 // where the default window bounds calculation is invoked.
101 TEST_F(WindowSizerAshTest, MAYBE_DefaultSizeCase) {
102 #if defined(OS_WIN)
103   CommandLine::ForCurrentProcess()->AppendSwitch(switches::kOpenAsh);
104 #endif
105   { // 4:3 monitor case, 1024x768, no taskbar
106     gfx::Rect window_bounds;
107     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), gfx::Rect(),
108                     gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds);
109     EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
110                         ash::WindowPositioner::kDesktopBorderSize,
111                         1024 - ash::WindowPositioner::kDesktopBorderSize * 2,
112                         768 - ash::WindowPositioner::kDesktopBorderSize),
113               window_bounds);
114   }
115
116   { // 4:3 monitor case, 1024x768, taskbar on bottom
117     gfx::Rect window_bounds;
118     GetWindowBounds(p1024x768, taskbar_bottom_work_area, gfx::Rect(),
119                     gfx::Rect(), gfx::Rect(), DEFAULT, NULL, gfx::Rect(),
120                     &window_bounds);
121     EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
122                         ash::WindowPositioner::kDesktopBorderSize,
123                         1024 - ash::WindowPositioner::kDesktopBorderSize * 2,
124                         taskbar_bottom_work_area.height() -
125                           ash::WindowPositioner::kDesktopBorderSize),
126               window_bounds);
127   }
128
129   { // 4:3 monitor case, 1024x768, taskbar on right
130     gfx::Rect window_bounds;
131     GetWindowBounds(p1024x768, taskbar_right_work_area, gfx::Rect(),
132                     gfx::Rect(), gfx::Rect(), DEFAULT, NULL, gfx::Rect(),
133                     &window_bounds);
134     EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
135                         ash::WindowPositioner::kDesktopBorderSize,
136                         taskbar_right_work_area.width() -
137                           ash::WindowPositioner::kDesktopBorderSize * 2,
138                         768 - ash::WindowPositioner::kDesktopBorderSize),
139               window_bounds);
140   }
141
142   { // 4:3 monitor case, 1024x768, taskbar on left
143     gfx::Rect window_bounds;
144     GetWindowBounds(p1024x768, taskbar_left_work_area, gfx::Rect(),
145                     gfx::Rect(), gfx::Rect(), DEFAULT, NULL, gfx::Rect(),
146                     &window_bounds);
147     EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() +
148                           ash::WindowPositioner::kDesktopBorderSize,
149                         ash::WindowPositioner::kDesktopBorderSize,
150                         taskbar_left_work_area.width() -
151                           ash::WindowPositioner::kDesktopBorderSize * 2,
152                         taskbar_left_work_area.height() -
153                           ash::WindowPositioner::kDesktopBorderSize),
154               window_bounds);
155   }
156
157   { // 4:3 monitor case, 1024x768, taskbar on top
158     gfx::Rect window_bounds;
159     GetWindowBounds(p1024x768, taskbar_top_work_area, gfx::Rect(),
160                     gfx::Rect(), gfx::Rect(), DEFAULT, NULL, gfx::Rect(),
161                     &window_bounds);
162     EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
163                         taskbar_top_work_area.y() +
164                           ash::WindowPositioner::kDesktopBorderSize,
165                         1024 - ash::WindowPositioner::kDesktopBorderSize * 2,
166                         taskbar_top_work_area.height() -
167                             ash::WindowPositioner::kDesktopBorderSize),
168               window_bounds);
169   }
170
171   { // 4:3 monitor case, 1280x1024
172     gfx::Rect window_bounds;
173     GetWindowBounds(p1280x1024, p1280x1024, gfx::Rect(), gfx::Rect(),
174                     gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds);
175     EXPECT_EQ(gfx::Rect((1280 - ash::WindowPositioner::kMaximumWindowWidth) / 2,
176                         ash::WindowPositioner::kDesktopBorderSize,
177                         ash::WindowPositioner::kMaximumWindowWidth,
178                         1024 - ash::WindowPositioner::kDesktopBorderSize),
179               window_bounds);
180   }
181
182   { // 4:3 monitor case, 1600x1200
183     gfx::Rect window_bounds;
184     GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), gfx::Rect(),
185                     gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds);
186     EXPECT_EQ(gfx::Rect((1600 - ash::WindowPositioner::kMaximumWindowWidth) / 2,
187                         ash::WindowPositioner::kDesktopBorderSize,
188                         ash::WindowPositioner::kMaximumWindowWidth,
189                         1200 - ash::WindowPositioner::kDesktopBorderSize),
190               window_bounds);
191   }
192
193   { // 16:10 monitor case, 1680x1050
194     gfx::Rect window_bounds;
195     GetWindowBounds(p1680x1050, p1680x1050, gfx::Rect(), gfx::Rect(),
196                     gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds);
197     EXPECT_EQ(gfx::Rect((1680 - ash::WindowPositioner::kMaximumWindowWidth) / 2,
198                         ash::WindowPositioner::kDesktopBorderSize,
199                         ash::WindowPositioner::kMaximumWindowWidth,
200                         1050 - ash::WindowPositioner::kDesktopBorderSize),
201               window_bounds);
202   }
203
204   { // 16:10 monitor case, 1920x1200
205     gfx::Rect window_bounds;
206     GetWindowBounds(p1920x1200, p1920x1200, gfx::Rect(), gfx::Rect(),
207                     gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds);
208     EXPECT_EQ(gfx::Rect((1920 - ash::WindowPositioner::kMaximumWindowWidth) / 2,
209                         ash::WindowPositioner::kDesktopBorderSize,
210                         ash::WindowPositioner::kMaximumWindowWidth,
211                         1200 - ash::WindowPositioner::kDesktopBorderSize),
212               window_bounds);
213   }
214 }
215
216 // Test that the next opened window is positioned appropriately given the
217 // bounds of an existing window of the same type.
218 TEST_F(WindowSizerAshTest, LastWindowBoundsCase) {
219   { // normal, in the middle of the screen somewhere.
220     gfx::Rect window_bounds;
221     GetWindowBounds(
222         p1024x768, p1024x768, gfx::Rect(),
223         gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
224                   ash::WindowPositioner::kDesktopBorderSize, 500, 400),
225         gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(),
226         &window_bounds);
227     EXPECT_EQ(
228         gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
229                   kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
230                   500, 400).ToString(),
231         window_bounds.ToString());
232   }
233
234   { // taskbar on top.
235     gfx::Rect window_bounds;
236     GetWindowBounds(
237         p1024x768, taskbar_top_work_area, gfx::Rect(),
238         gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
239                   ash::WindowPositioner::kDesktopBorderSize, 500, 400),
240         gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(),
241         &window_bounds);
242     EXPECT_EQ(
243         gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
244                   std::max(kWindowTilePixels +
245                            ash::WindowPositioner::kDesktopBorderSize,
246                            34 /* toolbar height */),
247                   500, 400).ToString(),
248         window_bounds.ToString());
249   }
250
251   { // Too small to satisify the minimum visibility condition.
252     gfx::Rect window_bounds;
253     GetWindowBounds(
254         p1024x768, p1024x768, gfx::Rect(),
255         gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
256                   ash::WindowPositioner::kDesktopBorderSize, 29, 29),
257         gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(),
258         &window_bounds);
259     EXPECT_EQ(
260         gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
261                   kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
262                   30 /* not 29 */,
263                   30 /* not 29 */).ToString(),
264         window_bounds.ToString());
265   }
266
267
268   { // Normal.
269     gfx::Rect window_bounds;
270     GetWindowBounds(
271         p1024x768, p1024x768, gfx::Rect(),
272         gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
273                   ash::WindowPositioner::kDesktopBorderSize, 500, 400),
274         gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(),
275         &window_bounds);
276     EXPECT_EQ(
277         gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
278                   kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
279                   500, 400).ToString(),
280         window_bounds.ToString());
281   }
282 }
283
284 // Test that the window opened is sized appropriately given persisted sizes.
285 TEST_F(WindowSizerAshTest, PersistedBoundsCase) {
286   { // normal, in the middle of the screen somewhere.
287     gfx::Rect initial_bounds(
288         ash::WindowPositioner::kDesktopBorderSize,
289         ash::WindowPositioner::kDesktopBorderSize, 500, 400);
290
291     gfx::Rect window_bounds;
292     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), initial_bounds,
293                     gfx::Rect(), PERSISTED, NULL, gfx::Rect(), &window_bounds);
294     EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString());
295   }
296
297   { // Normal.
298     gfx::Rect initial_bounds(0, 0, 1024, 768);
299
300     gfx::Rect window_bounds;
301     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), initial_bounds,
302                     gfx::Rect(), PERSISTED, NULL, gfx::Rect(), &window_bounds);
303     EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString());
304   }
305
306   { // normal, on non-primary monitor in negative coords.
307     gfx::Rect initial_bounds(-600, 10, 500, 400);
308
309     gfx::Rect window_bounds;
310     GetWindowBounds(p1024x768, p1024x768, left_s1024x768,
311                     initial_bounds, gfx::Rect(), PERSISTED, NULL, gfx::Rect(),
312                     &window_bounds);
313     EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString());
314   }
315
316   { // normal, on non-primary monitor in negative coords.
317     gfx::Rect initial_bounds(-1024, 0, 1024, 768);
318
319     gfx::Rect window_bounds;
320     GetWindowBounds(p1024x768, p1024x768, left_s1024x768,
321                     initial_bounds, gfx::Rect(), PERSISTED, NULL, gfx::Rect(),
322                     &window_bounds);
323     EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString());
324   }
325
326   { // Non-primary monitor resoultion has changed, but the monitor still
327     // completely contains the window.
328
329     gfx::Rect initial_bounds(1074, 50, 600, 500);
330
331     gfx::Rect window_bounds;
332     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(1024, 0, 800, 600),
333                     initial_bounds, right_s1024x768, PERSISTED, NULL,
334                     gfx::Rect(), &window_bounds);
335     EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString());
336   }
337
338   { // Non-primary monitor resoultion has changed, and the window is partially
339     // off-screen.
340
341     gfx::Rect initial_bounds(1274, 50, 600, 500);
342
343     gfx::Rect window_bounds;
344     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(1024, 0, 800, 600),
345                     initial_bounds, right_s1024x768, PERSISTED,
346                     NULL, gfx::Rect(), &window_bounds);
347     EXPECT_EQ("1224,50 600x500", window_bounds.ToString());
348   }
349
350   { // Non-primary monitor resoultion has changed, and the window is now too
351     // large for the monitor.
352
353     gfx::Rect initial_bounds(1274, 50, 900, 700);
354
355     gfx::Rect window_bounds;
356     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(1024, 0, 800, 600),
357                     initial_bounds, right_s1024x768, PERSISTED,
358                     NULL, gfx::Rect(), &window_bounds);
359     EXPECT_EQ("1024,0 800x600", window_bounds.ToString());
360   }
361
362   { // width and height too small
363     gfx::Rect window_bounds;
364     GetWindowBounds(
365         p1024x768, p1024x768, gfx::Rect(),
366         gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
367                   ash::WindowPositioner::kDesktopBorderSize, 29, 29),
368         gfx::Rect(), PERSISTED, NULL, gfx::Rect(), &window_bounds);
369     EXPECT_EQ(gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
370                         ash::WindowPositioner::kDesktopBorderSize,
371                         30 /* not 29 */, 30 /* not 29 */).ToString(),
372               window_bounds.ToString());
373   }
374 }
375
376 //////////////////////////////////////////////////////////////////////////////
377 // The following unittests have different results on Mac/non-Mac because we
378 // reposition windows aggressively on Mac.  The *WithAggressiveReposition tests
379 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on
380 // other platforms.
381
382 TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
383   { // taskbar on left.
384     gfx::Rect window_bounds;
385     GetWindowBounds(
386         p1024x768, taskbar_left_work_area, gfx::Rect(),
387         gfx::Rect(ash::WindowPositioner::kDesktopBorderSize,
388                   ash::WindowPositioner::kDesktopBorderSize, 500, 400),
389         gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(),
390         &window_bounds);
391     EXPECT_EQ(
392         gfx::Rect(kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
393                   kWindowTilePixels + ash::WindowPositioner::kDesktopBorderSize,
394                   500, 400).ToString(),
395         window_bounds.ToString());
396   }
397
398   { // offset would put the new window offscreen at the bottom but the minimum
399     // visibility condition is barely satisfied without relocation.
400     gfx::Rect window_bounds;
401     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(),
402                     gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE,
403                     NULL, gfx::Rect(), &window_bounds);
404     EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, 500, 400).ToString(),
405               window_bounds.ToString());
406   }
407
408   { // offset would put the new window offscreen at the bottom and the minimum
409     // visibility condition is satisified by relocation.
410     gfx::Rect window_bounds;
411     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(),
412                     gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
413                     NULL, gfx::Rect(), &window_bounds);
414     EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels,
415                         738 /* not 739 */,
416                         500,
417                         400).ToString(),
418               window_bounds.ToString());
419   }
420
421   { // offset would put the new window offscreen at the right but the minimum
422     // visibility condition is barely satisfied without relocation.
423     gfx::Rect window_bounds;
424     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(),
425                     gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
426                     NULL, gfx::Rect(), &window_bounds);
427     EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400).ToString(),
428               window_bounds.ToString());
429   }
430
431   { // offset would put the new window offscreen at the right and the minimum
432     // visibility condition is satisified by relocation.
433     gfx::Rect window_bounds;
434     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(),
435                     gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
436                     NULL, gfx::Rect(), &window_bounds);
437     EXPECT_EQ(gfx::Rect(994 /* not 995 */,
438                         10 + kWindowTilePixels,
439                         500,
440                         400).ToString(),
441               window_bounds.ToString());
442   }
443
444   { // offset would put the new window offscreen at the bottom right and the
445     // minimum visibility condition is satisified by relocation.
446     gfx::Rect window_bounds;
447     GetWindowBounds(p1024x768, p1024x768, gfx::Rect(),
448                     gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
449                     NULL, gfx::Rect(), &window_bounds);
450     EXPECT_EQ(gfx::Rect(994 /* not 995 */,
451                         738 /* not 739 */,
452                         500,
453                         400).ToString(),
454               window_bounds.ToString());
455   }
456 }
457
458 // On desktop linux aura, we currently don't use the ash frame, breaking some
459 // tests which expect ash sizes: http://crbug.com/303862
460 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
461 #define MAYBE_PlaceNewWindows DISABLED_PlaceNewWindows
462 #else
463 #define MAYBE_PlaceNewWindows PlaceNewWindows
464 #endif
465
466 // Test the placement of newly created windows.
467 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindows) {
468   // Create a browser to pass into the GetWindowBounds function.
469   scoped_ptr<TestingProfile> profile(new TestingProfile());
470   // Creating a popup handler here to make sure it does not interfere with the
471   // existing windows.
472   Browser::CreateParams native_params(profile.get(),
473                                       chrome::HOST_DESKTOP_TYPE_ASH);
474   scoped_ptr<Browser> browser(
475       chrome::CreateBrowserWithTestWindowForParams(&native_params));
476
477   // Creating a popup handler here to make sure it does not interfere with the
478   // existing windows.
479   scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow(
480       CreateTestWindowInShellWithId(0),
481       gfx::Rect(16, 32, 640, 320),
482       Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH)));
483
484   // Creating a popup to make sure it does not interfere with the positioning.
485   scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow(
486       CreateTestWindowInShellWithId(1),
487       gfx::Rect(16, 32, 128, 256),
488       Browser::CreateParams(Browser::TYPE_POPUP, profile.get(),
489                             chrome::HOST_DESKTOP_TYPE_ASH)));
490
491   // Creating a panel to make sure it does not interfere with the positioning.
492   scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow(
493       CreateTestWindowInShellWithId(2),
494       gfx::Rect(32, 48, 256, 512),
495       Browser::CreateParams(Browser::TYPE_POPUP, profile.get(),
496                             chrome::HOST_DESKTOP_TYPE_ASH)));
497   browser_window->Show();
498   { // Make sure that popups do not get changed.
499     gfx::Rect window_bounds;
500     GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(),
501                     gfx::Rect(50, 100, 300, 150), bottom_s1600x1200,
502                     PERSISTED, browser_popup->browser(),
503                     gfx::Rect(), &window_bounds);
504     EXPECT_EQ("50,100 300x150", window_bounds.ToString());
505   }
506
507   browser_window->Hide();
508   { // If a window is there but not shown the persisted default should be used.
509     gfx::Rect window_bounds;
510     GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(),
511                     gfx::Rect(50, 100, 300, 150), bottom_s1600x1200,
512                     PERSISTED, browser.get(), gfx::Rect(), &window_bounds);
513     EXPECT_EQ("50,100 300x150", window_bounds.ToString());
514   }
515
516   { // If a window is there but not shown the default should be returned.
517     gfx::Rect window_bounds;
518     GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(),
519                     gfx::Rect(), bottom_s1600x1200,
520                     DEFAULT, browser.get(), gfx::Rect(), &window_bounds);
521     // Note: We need to also take the defaults maximum width into account here
522     // since that might get used if the resolution is too big.
523     EXPECT_EQ(
524         gfx::Rect(
525             std::max(ash::WindowPositioner::kDesktopBorderSize,
526                      (1600 - ash::WindowPositioner::kMaximumWindowWidth) / 2),
527             ash::WindowPositioner::kDesktopBorderSize,
528             std::min(ash::WindowPositioner::kMaximumWindowWidth,
529                      1600 - 2 * ash::WindowPositioner::kDesktopBorderSize),
530             1200 - ash::WindowPositioner::kDesktopBorderSize).ToString(),
531         window_bounds.ToString());
532   }
533 }
534
535 // On desktop linux aura, we currently don't use the ash frame, breaking some
536 // tests which expect ash sizes: http://crbug.com/303862
537 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
538 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop DISABLED_PlaceNewBrowserWindowOnEmptyDesktop
539 #else
540 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop PlaceNewBrowserWindowOnEmptyDesktop
541 #endif
542
543 // Test the placement of newly created windows on an empty desktop.
544 // This test supplements "PlaceNewWindows" by testing the creation of a newly
545 // created browser window on an empty desktop.
546 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewBrowserWindowOnEmptyDesktop) {
547   // Create a browser to pass into the GetWindowBoundsAndShowState function.
548   scoped_ptr<TestingProfile> profile(new TestingProfile());
549   Browser::CreateParams native_params(profile.get(),
550                                       chrome::HOST_DESKTOP_TYPE_ASH);
551   scoped_ptr<Browser> browser(
552       chrome::CreateBrowserWithTestWindowForParams(&native_params));
553
554   // A common screen size for Chrome OS devices where this behavior is
555   // desirable.
556   const gfx::Rect p1366x768(0, 0, 1366, 768);
557
558   // If there is no previous state the window should get maximized if the
559   // screen is less than or equal to our limit (1366 pixels width).
560   gfx::Rect window_bounds;
561   ui::WindowShowState out_show_state1 = ui::SHOW_STATE_DEFAULT;
562   GetWindowBoundsAndShowState(
563       p1366x768,                    // The screen resolution.
564       p1366x768,                    // The monitor work area.
565       gfx::Rect(),                  // The second monitor.
566       gfx::Rect(),                  // The (persisted) bounds.
567       p1366x768,                    // The overall work area.
568       ui::SHOW_STATE_NORMAL,        // The persisted show state.
569       ui::SHOW_STATE_DEFAULT,       // The last show state.
570       DEFAULT,                      // No persisted values.
571       browser.get(),                // Use this browser.
572       gfx::Rect(),                  // Don't request valid bounds.
573       &window_bounds,
574       &out_show_state1);
575   EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, out_show_state1);
576
577   // If there is a stored coordinate however, that should be taken instead.
578   ui::WindowShowState out_show_state2 = ui::SHOW_STATE_DEFAULT;
579   GetWindowBoundsAndShowState(
580       p1366x768,                    // The screen resolution.
581       p1366x768,                    // The monitor work area.
582       gfx::Rect(),                  // The second monitor.
583       gfx::Rect(50, 100, 300, 150), // The (persisted) bounds.
584       p1366x768,                    // The overall work area.
585       ui::SHOW_STATE_NORMAL,        // The persisted show state.
586       ui::SHOW_STATE_DEFAULT,       // The last show state.
587       PERSISTED,                    // Set the persisted values.
588       browser.get(),                // Use this browser.
589       gfx::Rect(),                  // Don't request valid bounds.
590       &window_bounds,
591       &out_show_state2);
592   EXPECT_EQ(ui::SHOW_STATE_NORMAL, out_show_state2);
593   EXPECT_EQ("50,100 300x150", window_bounds.ToString());
594
595   // A larger monitor should not trigger auto-maximize.
596   ui::WindowShowState out_show_state3 = ui::SHOW_STATE_DEFAULT;
597   GetWindowBoundsAndShowState(
598       p1600x1200,                   // The screen resolution.
599       p1600x1200,                   // The monitor work area.
600       gfx::Rect(),                  // The second monitor.
601       gfx::Rect(),                  // The (persisted) bounds.
602       p1600x1200,                   // The overall work area.
603       ui::SHOW_STATE_NORMAL,        // The persisted show state.
604       ui::SHOW_STATE_DEFAULT,       // The last show state.
605       DEFAULT,                      // No persisted values.
606       browser.get(),                // Use this browser.
607       gfx::Rect(),                  // Don't request valid bounds.
608       &window_bounds,
609       &out_show_state3);
610 #if defined(OS_WIN)
611   EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, out_show_state3);
612 #else
613   EXPECT_EQ(ui::SHOW_STATE_DEFAULT, out_show_state3);
614 #endif
615 }
616
617 #if defined(OS_CHROMEOS)
618 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplays
619 #else
620 // No multiple displays on windows ash.
621 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultipleDisplays
622 #endif
623
624 // Test the placement of newly created windows on multiple dislays.
625 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) {
626   UpdateDisplay("1600x1200,1600x1200");
627   gfx::Rect primary_bounds = ash::Shell::GetInstance()->GetScreen()->
628       GetPrimaryDisplay().bounds();
629   gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds();
630
631   ash::Shell::GetInstance()->set_target_root_window(
632       ash::Shell::GetPrimaryRootWindow());
633
634   scoped_ptr<TestingProfile> profile(new TestingProfile());
635
636   // Create browser windows that are used as reference.
637   scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow(
638       CreateTestWindowInShellWithId(0),
639       gfx::Rect(10, 10, 200, 200),
640       Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH)));
641   browser_window->Show();
642   EXPECT_EQ(browser_window->GetNativeWindow()->GetRootWindow(),
643             ash::Shell::GetTargetRootWindow());
644
645   scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow(
646       CreateTestWindowInShellWithId(1),
647       gfx::Rect(400, 10, 300, 300),
648       Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH)));
649   another_browser_window->Show();
650
651   // Creating a new window to verify the new placement.
652   scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow(
653       CreateTestWindowInShellWithId(0),
654       gfx::Rect(),
655       Browser::CreateParams(profile.get(),
656                             chrome::HOST_DESKTOP_TYPE_ASH)));
657
658   // Make sure the primary root is active.
659   ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(),
660             ash::Shell::GetTargetRootWindow());
661
662   // First new window should be in the primary.
663   {
664     gfx::Rect window_bounds;
665     GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds,
666                     gfx::Rect(), secondary_bounds,
667                     PERSISTED, new_browser_window->browser(),
668                     gfx::Rect(), &window_bounds);
669     // TODO(oshima): Use exact bounds when the window_sizer_ash is
670     // moved to ash and changed to include the result from
671     // RearrangeVisibleWindowOnShow.
672     EXPECT_TRUE(primary_bounds.Contains(window_bounds));
673   }
674
675   // Move the window to the right side of the secondary display and create a new
676   // window. It should be opened then on the secondary display.
677   {
678     gfx::Display second_display = ash::Shell::GetScreen()->
679         GetDisplayNearestPoint(gfx::Point(1600 + 100,10));
680     browser_window->GetNativeWindow()->SetBoundsInScreen(
681         gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200),
682         second_display);
683     browser_window->Activate();
684     EXPECT_NE(ash::Shell::GetPrimaryRootWindow(),
685               ash::Shell::GetTargetRootWindow());
686     gfx::Rect window_bounds;
687     GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds,
688                     gfx::Rect(), secondary_bounds,
689                     PERSISTED, new_browser_window->browser(),
690                     gfx::Rect(), &window_bounds);
691     // TODO(oshima): Use exact bounds when the window_sizer_ash is
692     // moved to ash and changed to include the result from
693     // RearrangeVisibleWindowOnShow.
694     EXPECT_TRUE(secondary_bounds.Contains(window_bounds));
695   }
696
697   // Activate another window in the primary display and create a new window.
698   // It should be created in the primary display.
699   {
700     another_browser_window->Activate();
701     EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(),
702               ash::Shell::GetTargetRootWindow());
703
704     gfx::Rect window_bounds;
705     GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds,
706                     gfx::Rect(), secondary_bounds,
707                     PERSISTED, new_browser_window->browser(),
708                     gfx::Rect(), &window_bounds);
709     // TODO(oshima): Use exact bounds when the window_sizer_ash is
710     // moved to ash and changed to include the result from
711     // RearrangeVisibleWindowOnShow.
712     EXPECT_TRUE(primary_bounds.Contains(window_bounds));
713   }
714 }
715
716 // On desktop linux aura, we currently don't use the ash frame, breaking some
717 // tests which expect ash sizes: http://crbug.com/303862
718 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
719 #define MAYBE_TestShowState DISABLED_TestShowState
720 #else
721 #define MAYBE_TestShowState TestShowState
722 #endif
723
724 // Test that the show state is properly returned for non default cases.
725 TEST_F(WindowSizerAshTest, MAYBE_TestShowState) {
726   scoped_ptr<TestingProfile> profile(new TestingProfile());
727
728   // Creating a browser & window to play with.
729   scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow(
730       CreateTestWindowInShellWithId(0),
731       gfx::Rect(16, 32, 640, 320),
732       Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
733                             chrome::HOST_DESKTOP_TYPE_ASH)));
734
735   // Create also a popup browser since that behaves different.
736   scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow(
737       CreateTestWindowInShellWithId(1),
738       gfx::Rect(16, 32, 640, 320),
739       Browser::CreateParams(Browser::TYPE_POPUP, profile.get(),
740                             chrome::HOST_DESKTOP_TYPE_ASH)));
741
742   // Tabbed windows should retrieve the saved window state - since there is a
743   // top window.
744   EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
745             GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
746                                ui::SHOW_STATE_NORMAL,
747                                BOTH,
748                                browser_window->browser(),
749                                p1600x1200,
750                                p1600x1200));
751   // A window that is smaller than the whole work area is set to default state.
752   EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
753             GetWindowShowState(ui::SHOW_STATE_DEFAULT,
754                                ui::SHOW_STATE_NORMAL,
755                                BOTH,
756                                browser_window->browser(),
757                                p1280x1024,
758                                p1600x1200));
759   // A window that is sized to occupy the whole work area is maximized.
760   EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
761             GetWindowShowState(ui::SHOW_STATE_DEFAULT,
762                                ui::SHOW_STATE_NORMAL,
763                                BOTH,
764                                browser_window->browser(),
765                                p1600x1200,
766                                p1600x1200));
767   // Non tabbed windows should always follow the window saved visibility state.
768   EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
769             GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
770                                ui::SHOW_STATE_NORMAL,
771                                BOTH,
772                                browser_popup->browser(),
773                                p1600x1200,
774                                p1600x1200));
775   // The non tabbed window will take the status of the last active of its kind.
776   EXPECT_EQ(ui::SHOW_STATE_NORMAL,
777             GetWindowShowState(ui::SHOW_STATE_DEFAULT,
778                                ui::SHOW_STATE_NORMAL,
779                                BOTH,
780                                browser_popup->browser(),
781                                p1600x1200,
782                                p1600x1200));
783
784   // Now create a top level window and check again for both. Only the tabbed
785   // window should follow the top level window's state.
786   // Creating a browser & window to play with.
787   scoped_ptr<TestBrowserWindowAura> browser_window2(CreateTestBrowserWindow(
788       CreateTestWindowInShellWithId(3),
789       gfx::Rect(16, 32, 640, 320),
790       Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
791                             chrome::HOST_DESKTOP_TYPE_ASH)));
792
793   // A tabbed window should now take the top level window state.
794   EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
795             GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
796                                ui::SHOW_STATE_DEFAULT,
797                                BOTH,
798                                browser_window->browser(),
799                                p1600x1200,
800                                p1600x1200));
801   // Non tabbed windows should always follow the window saved visibility state.
802   EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
803             GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
804                                ui::SHOW_STATE_MINIMIZED,
805                                BOTH,
806                                browser_popup->browser(),
807                                p1600x1200,
808                                p1600x1200));
809
810   // In smaller screen resolutions we default to maximized if there is no other
811   // window visible.
812   int min_size = ash::WindowPositioner::GetForceMaximizedWidthLimit() / 2;
813   if (min_size > 0) {
814     const gfx::Rect tiny_screen(0, 0, min_size, min_size);
815     EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
816               GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
817                                  ui::SHOW_STATE_DEFAULT,
818                                  BOTH,
819                                  browser_window->browser(),
820                                  tiny_screen,
821                                  tiny_screen));
822     browser_window->Hide();
823     EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
824               GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
825                                  ui::SHOW_STATE_DEFAULT,
826                                  BOTH,
827                                  browser_window2->browser(),
828                                  tiny_screen,
829                                  tiny_screen));
830
831   }
832 }
833
834 // Test that the default show state override behavior is properly handled.
835 TEST_F(WindowSizerAshTest, TestShowStateDefaults) {
836   // Creating a browser & window to play with.
837   scoped_ptr<TestingProfile> profile(new TestingProfile());
838
839   scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow(
840       CreateTestWindowInShellWithId(0),
841       gfx::Rect(16, 32, 640, 320),
842       Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
843                             chrome::HOST_DESKTOP_TYPE_ASH)));
844
845   // Create also a popup browser since that behaves slightly different for
846   // defaults.
847   scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow(
848       CreateTestWindowInShellWithId(1),
849       gfx::Rect(16, 32, 128, 256),
850       Browser::CreateParams(Browser::TYPE_POPUP, profile.get(),
851                             chrome::HOST_DESKTOP_TYPE_ASH)));
852
853   // Check that a browser creation state always get used if not given as
854   // SHOW_STATE_DEFAULT. On Windows ASH it should be SHOW_STATE_MAXIMIZED.
855   ui::WindowShowState window_show_state =
856       GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
857                          ui::SHOW_STATE_MAXIMIZED,
858                          DEFAULT,
859                          browser_window->browser(),
860                          p1600x1200,
861                          p1600x1200);
862 #if defined(OS_WIN)
863   EXPECT_EQ(window_show_state, ui::SHOW_STATE_MAXIMIZED);
864 #else
865   EXPECT_EQ(window_show_state, ui::SHOW_STATE_DEFAULT);
866 #endif
867
868   browser_window->browser()->set_initial_show_state(ui::SHOW_STATE_MINIMIZED);
869   EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
870                                ui::SHOW_STATE_MAXIMIZED,
871                                BOTH,
872                                browser_window->browser(),
873                                p1600x1200,
874                                p1600x1200), ui::SHOW_STATE_MINIMIZED);
875   browser_window->browser()->set_initial_show_state(ui::SHOW_STATE_NORMAL);
876   EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
877                                ui::SHOW_STATE_MAXIMIZED,
878                                BOTH,
879                                browser_window->browser(),
880                                p1600x1200,
881                                p1600x1200), ui::SHOW_STATE_NORMAL);
882   browser_window->browser()->set_initial_show_state(ui::SHOW_STATE_MAXIMIZED);
883   EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL,
884                                ui::SHOW_STATE_NORMAL,
885                                BOTH,
886                                browser_window->browser(),
887                                p1600x1200,
888                                p1600x1200), ui::SHOW_STATE_MAXIMIZED);
889
890   // Check that setting the maximized command line option is forcing the
891   // maximized state.
892   CommandLine::ForCurrentProcess()->AppendSwitch(switches::kStartMaximized);
893
894   browser_window->browser()->set_initial_show_state(ui::SHOW_STATE_NORMAL);
895   EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL,
896                                ui::SHOW_STATE_NORMAL,
897                                BOTH,
898                                browser_window->browser(),
899                                p1600x1200,
900                                p1600x1200), ui::SHOW_STATE_MAXIMIZED);
901
902   // The popup should favor the initial show state over the command line.
903   EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL,
904                                ui::SHOW_STATE_NORMAL,
905                                BOTH,
906                                browser_popup->browser(),
907                                p1600x1200,
908                                p1600x1200), ui::SHOW_STATE_NORMAL);
909 }
910
911 TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) {
912   // Create a browser to pass into the GetWindowBounds function.
913   scoped_ptr<TestingProfile> profile(new TestingProfile());
914   Browser::CreateParams native_params(profile.get(),
915                                       chrome::HOST_DESKTOP_TYPE_ASH);
916   scoped_ptr<Browser> browser(
917       chrome::CreateBrowserWithTestWindowForParams(&native_params));
918
919   gfx::Rect display_bounds = ash::Shell::GetInstance()->GetScreen()->
920       GetPrimaryDisplay().bounds();
921   gfx::Rect specified_bounds = display_bounds;
922
923   // Make a window bigger than the display work area.
924   specified_bounds.Inset(-20, -20);
925   ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT;
926   gfx::Rect bounds;
927   WindowSizer::GetBrowserWindowBoundsAndShowState(
928       std::string(), specified_bounds, browser.get(), &bounds, &show_state);
929   // The window should start maximized with its restore bounds shrunken.
930   EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, show_state);
931   EXPECT_NE(display_bounds.ToString(), bounds.ToString());
932   EXPECT_TRUE(display_bounds.Contains(bounds));
933
934   // Make a window smaller than the display work area.
935   specified_bounds.Inset(100, 100);
936   show_state = ui::SHOW_STATE_DEFAULT;
937   WindowSizer::GetBrowserWindowBoundsAndShowState(
938       std::string(), specified_bounds, browser.get(), &bounds, &show_state);
939   // The window should start in default state.
940   EXPECT_EQ(ui::SHOW_STATE_DEFAULT, show_state);
941   EXPECT_EQ(specified_bounds.ToString(), bounds.ToString());
942 }
943
944 // Test that the target root window is used as the destination of
945 // the non browser window. This differ from PersistedBoundsCase
946 // in that this uses real ash shell implementations + StateProvider
947 // TargetDisplayProvider, rather than mocks.
948 TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) {
949   if (!SupportsMultipleDisplays() || !chrome::ShouldOpenAshOnStartup())
950     return;
951   UpdateDisplay("500x500,600x600");
952   {
953     aura::Window* first_root =
954         ash::Shell::GetAllRootWindows()[0];
955     ash::ScopedTargetRootWindow tmp(first_root);
956     gfx::Rect bounds;
957     ui::WindowShowState show_state;
958     WindowSizer::GetBrowserWindowBoundsAndShowState(
959         std::string(),
960         gfx::Rect(),
961         NULL,
962         &bounds,
963         &show_state);
964     EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds));
965   }
966   {
967     aura::Window* second_root =
968         ash::Shell::GetAllRootWindows()[1];
969     ash::ScopedTargetRootWindow tmp(second_root);
970     gfx::Rect bounds;
971     ui::WindowShowState show_state;
972     WindowSizer::GetBrowserWindowBoundsAndShowState(
973         std::string(),
974         gfx::Rect(),
975         NULL,
976         &bounds,
977         &show_state);
978     EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds));
979   }
980 }
981
982 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) {
983   scoped_ptr<TestingProfile> profile(new TestingProfile());
984   Browser::CreateParams trusted_popup_create_params(
985       Browser::TYPE_POPUP, profile.get(), chrome::HOST_DESKTOP_TYPE_ASH);
986   trusted_popup_create_params.trusted_source = true;
987
988   scoped_ptr<TestBrowserWindowAura> trusted_popup(CreateTestBrowserWindow(
989       CreateTestWindowInShellWithId(1),
990       gfx::Rect(16, 32, 640, 320),
991       trusted_popup_create_params));
992   // Trusted popup windows should follow the saved show state and ignore the
993   // last show state.
994   EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
995             GetWindowShowState(ui::SHOW_STATE_DEFAULT,
996                                ui::SHOW_STATE_NORMAL,
997                                BOTH,
998                                trusted_popup->browser(),
999                                p1280x1024,
1000                                p1600x1200));
1001   // A popup that is sized to occupy the whole work area has default state.
1002   EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
1003             GetWindowShowState(ui::SHOW_STATE_DEFAULT,
1004                                ui::SHOW_STATE_NORMAL,
1005                                BOTH,
1006                                trusted_popup->browser(),
1007                                p1600x1200,
1008                                p1600x1200));
1009 }