Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc

Issue 11421006: Desktop aura: Break aura::Window::SetParent in two. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ash_unittests Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" 5 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/test/test_shell_delegate.h" 9 #include "ash/test/test_shell_delegate.h"
10 #include "ash/wm/window_resizer.h" 10 #include "ash/wm/window_resizer.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 738 /* not 739 */, 438 738 /* not 739 */,
439 500, 439 500,
440 400).ToString(), 440 400).ToString(),
441 window_bounds.ToString()); 441 window_bounds.ToString());
442 } 442 }
443 } 443 }
444 444
445 // Test the placement of newly created windows. 445 // Test the placement of newly created windows.
446 TEST_F(WindowSizerTestWithBrowser, PlaceNewWindows) { 446 TEST_F(WindowSizerTestWithBrowser, PlaceNewWindows) {
447 // Create a dummy window. 447 // Create a dummy window.
448 scoped_ptr<aura::Window> window( 448 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
449 aura::test::CreateTestWindowWithId(0, NULL));
450 window->SetBounds(gfx::Rect(16, 32, 640, 320)); 449 window->SetBounds(gfx::Rect(16, 32, 640, 320));
451 450
452 scoped_ptr<aura::Window> popup( 451 scoped_ptr<aura::Window> popup(CreateTestWindowInShellWithId(1));
453 aura::test::CreateTestWindowWithId(1, NULL));
454 popup->SetBounds(gfx::Rect(16, 32, 128, 256)); 452 popup->SetBounds(gfx::Rect(16, 32, 128, 256));
455 453
456 scoped_ptr<aura::Window> panel( 454 scoped_ptr<aura::Window> panel(CreateTestWindowInShellWithId(2));
457 aura::test::CreateTestWindowWithId(2, NULL));
458 panel->SetBounds(gfx::Rect(32, 48, 256, 512)); 455 panel->SetBounds(gfx::Rect(32, 48, 256, 512));
459 456
460 // Create a browser which we can use to pass into the GetWindowBounds 457 // Create a browser which we can use to pass into the GetWindowBounds
461 // function. 458 // function.
462 scoped_ptr<TestingProfile> profile(new TestingProfile()); 459 scoped_ptr<TestingProfile> profile(new TestingProfile());
463 // Creating a popup handler here to make sure it does not interfere with the 460 // Creating a popup handler here to make sure it does not interfere with the
464 // existing windows. 461 // existing windows.
465 scoped_ptr<Browser> browser( 462 scoped_ptr<Browser> browser(
466 chrome::CreateBrowserWithTestWindowForProfile(profile.get())); 463 chrome::CreateBrowserWithTestWindowForProfile(profile.get()));
467 464
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 WindowSizer::kDesktopBorderSize, 547 WindowSizer::kDesktopBorderSize,
551 1024 - 2 * WindowSizer::kDesktopBorderSize, 548 1024 - 2 * WindowSizer::kDesktopBorderSize,
552 768 - WindowSizer::kDesktopBorderSize).ToString(), 549 768 - WindowSizer::kDesktopBorderSize).ToString(),
553 window_bounds.ToString()); 550 window_bounds.ToString());
554 } 551 }
555 } 552 }
556 553
557 // Test that the show state is properly returned for non default cases. 554 // Test that the show state is properly returned for non default cases.
558 TEST_F(WindowSizerTestWithBrowser, TestShowState) { 555 TEST_F(WindowSizerTestWithBrowser, TestShowState) {
559 // Creating a browser & window to play with. 556 // Creating a browser & window to play with.
560 scoped_ptr<aura::Window> window( 557 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
561 aura::test::CreateTestWindowWithId(0, NULL));
562 window->SetBounds(gfx::Rect(16, 32, 640, 320)); 558 window->SetBounds(gfx::Rect(16, 32, 640, 320));
563 559
564 scoped_ptr<TestingProfile> profile(new TestingProfile()); 560 scoped_ptr<TestingProfile> profile(new TestingProfile());
565 561
566 scoped_ptr<BrowserWindow> browser_window( 562 scoped_ptr<BrowserWindow> browser_window(
567 new TestBrowserWindowAura(window.get())); 563 new TestBrowserWindowAura(window.get()));
568 Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get()); 564 Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get());
569 window_params.window = browser_window.get(); 565 window_params.window = browser_window.get();
570 scoped_ptr<Browser> browser(new Browser(window_params)); 566 scoped_ptr<Browser> browser(new Browser(window_params));
571 567
572 // Create also a popup browser since that behaves different. 568 // Create also a popup browser since that behaves different.
573 scoped_ptr<aura::Window> popup( 569 scoped_ptr<aura::Window> popup(CreateTestWindowInShellWithId(1));
574 aura::test::CreateTestWindowWithId(1, NULL));
575 popup->SetBounds(gfx::Rect(16, 32, 128, 256)); 570 popup->SetBounds(gfx::Rect(16, 32, 128, 256));
576 571
577 scoped_ptr<BrowserWindow> browser_popup( 572 scoped_ptr<BrowserWindow> browser_popup(
578 new TestBrowserWindowAura(popup.get())); 573 new TestBrowserWindowAura(popup.get()));
579 Browser::CreateParams popup_params(Browser::TYPE_POPUP, profile.get()); 574 Browser::CreateParams popup_params(Browser::TYPE_POPUP, profile.get());
580 popup_params.window = browser_window.get(); 575 popup_params.window = browser_window.get();
581 scoped_ptr<Browser> popup_browser(new Browser(popup_params)); 576 scoped_ptr<Browser> popup_browser(new Browser(popup_params));
582 577
583 // Tabbed windows should retrieve the saved window state - since there is a 578 // Tabbed windows should retrieve the saved window state - since there is a
584 // top window. 579 // top window.
(...skipping 16 matching lines...) Expand all
601 // The non tabbed window will take the status of the last active of its kind. 596 // The non tabbed window will take the status of the last active of its kind.
602 EXPECT_EQ(ui::SHOW_STATE_NORMAL, 597 EXPECT_EQ(ui::SHOW_STATE_NORMAL,
603 GetWindowShowState(ui::SHOW_STATE_DEFAULT, 598 GetWindowShowState(ui::SHOW_STATE_DEFAULT,
604 ui::SHOW_STATE_NORMAL, 599 ui::SHOW_STATE_NORMAL,
605 BOTH, 600 BOTH,
606 popup_browser.get())); 601 popup_browser.get()));
607 602
608 // Now create a top level window and check again for both. Only the tabbed 603 // Now create a top level window and check again for both. Only the tabbed
609 // window should follow the top level window's state. 604 // window should follow the top level window's state.
610 // Creating a browser & window to play with. 605 // Creating a browser & window to play with.
611 scoped_ptr<aura::Window> window2( 606 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0));
612 aura::test::CreateTestWindowWithId(0, NULL));
613 window->SetBounds(gfx::Rect(16, 32, 640, 320)); 607 window->SetBounds(gfx::Rect(16, 32, 640, 320));
614 608
615 scoped_ptr<BrowserWindow> browser_window2( 609 scoped_ptr<BrowserWindow> browser_window2(
616 new TestBrowserWindowAura(window2.get())); 610 new TestBrowserWindowAura(window2.get()));
617 Browser::CreateParams window2_params(Browser::TYPE_TABBED, profile.get()); 611 Browser::CreateParams window2_params(Browser::TYPE_TABBED, profile.get());
618 window2_params.window = browser_window2.get(); 612 window2_params.window = browser_window2.get();
619 scoped_ptr<Browser> browser2(new Browser(window2_params)); 613 scoped_ptr<Browser> browser2(new Browser(window2_params));
620 614
621 // A tabbed window should now take the top level window state. 615 // A tabbed window should now take the top level window state.
622 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, 616 EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
623 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 617 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
624 ui::SHOW_STATE_DEFAULT, 618 ui::SHOW_STATE_DEFAULT,
625 BOTH, 619 BOTH,
626 browser2.get())); 620 browser2.get()));
627 // Non tabbed windows should always follow the window saved visibility state. 621 // Non tabbed windows should always follow the window saved visibility state.
628 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, 622 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED,
629 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 623 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
630 ui::SHOW_STATE_MINIMIZED, 624 ui::SHOW_STATE_MINIMIZED,
631 BOTH, 625 BOTH,
632 popup_browser.get())); 626 popup_browser.get()));
633 } 627 }
634 628
635 // Test that the default show state override behavior is properly handled. 629 // Test that the default show state override behavior is properly handled.
636 TEST_F(WindowSizerTestWithBrowser, TestShowStateDefaults) { 630 TEST_F(WindowSizerTestWithBrowser, TestShowStateDefaults) {
637 // Creating a browser & window to play with. 631 // Creating a browser & window to play with.
638 scoped_ptr<aura::Window> window( 632 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
639 aura::test::CreateTestWindowWithId(0, NULL));
640 window->SetBounds(gfx::Rect(16, 32, 640, 320)); 633 window->SetBounds(gfx::Rect(16, 32, 640, 320));
641 634
642 scoped_ptr<TestingProfile> profile(new TestingProfile()); 635 scoped_ptr<TestingProfile> profile(new TestingProfile());
643 636
644 scoped_ptr<BrowserWindow> browser_window( 637 scoped_ptr<BrowserWindow> browser_window(
645 new TestBrowserWindowAura(window.get())); 638 new TestBrowserWindowAura(window.get()));
646 Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get()); 639 Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get());
647 window_params.window = browser_window.get(); 640 window_params.window = browser_window.get();
648 scoped_ptr<Browser> browser(new Browser(window_params)); 641 scoped_ptr<Browser> browser(new Browser(window_params));
649 642
650 // Create also a popup browser since that behaves slightly different for 643 // Create also a popup browser since that behaves slightly different for
651 // defaults. 644 // defaults.
652 scoped_ptr<aura::Window> popup( 645 scoped_ptr<aura::Window> popup(CreateTestWindowInShellWithId(1));
653 aura::test::CreateTestWindowWithId(1, NULL));
654 popup->SetBounds(gfx::Rect(16, 32, 128, 256)); 646 popup->SetBounds(gfx::Rect(16, 32, 128, 256));
655 647
656 scoped_ptr<BrowserWindow> browser_popup( 648 scoped_ptr<BrowserWindow> browser_popup(
657 new TestBrowserWindowAura(popup.get())); 649 new TestBrowserWindowAura(popup.get()));
658 Browser::CreateParams popup_params(Browser::TYPE_POPUP, profile.get()); 650 Browser::CreateParams popup_params(Browser::TYPE_POPUP, profile.get());
659 popup_params.window = browser_window.get(); 651 popup_params.window = browser_window.get();
660 scoped_ptr<Browser> popup_browser(new Browser(popup_params)); 652 scoped_ptr<Browser> popup_browser(new Browser(popup_params));
661 653
662 // Check that a browser creation state always get used if not given as 654 // Check that a browser creation state always get used if not given as
663 // SHOW_STATE_DEFAULT. 655 // SHOW_STATE_DEFAULT.
(...skipping 26 matching lines...) Expand all
690 ui::SHOW_STATE_NORMAL, 682 ui::SHOW_STATE_NORMAL,
691 BOTH, 683 BOTH,
692 browser.get()), ui::SHOW_STATE_MAXIMIZED); 684 browser.get()), ui::SHOW_STATE_MAXIMIZED);
693 685
694 // The popup should favor the initial show state over the command line. 686 // The popup should favor the initial show state over the command line.
695 EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, 687 EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL,
696 ui::SHOW_STATE_NORMAL, 688 ui::SHOW_STATE_NORMAL,
697 BOTH, 689 BOTH,
698 popup_browser.get()), ui::SHOW_STATE_NORMAL); 690 popup_browser.get()), ui::SHOW_STATE_NORMAL);
699 } 691 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/window_positioner_unittest.cc ('k') | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698