OLD | NEW |
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 "ash/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 363 } |
364 | 364 |
365 TEST_F(ShellTest, LockScreenClosesActiveMenu) { | 365 TEST_F(ShellTest, LockScreenClosesActiveMenu) { |
366 SimpleMenuDelegate menu_delegate; | 366 SimpleMenuDelegate menu_delegate; |
367 scoped_ptr<ui::SimpleMenuModel> menu_model( | 367 scoped_ptr<ui::SimpleMenuModel> menu_model( |
368 new ui::SimpleMenuModel(&menu_delegate)); | 368 new ui::SimpleMenuModel(&menu_delegate)); |
369 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item")); | 369 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item")); |
370 views::Widget* widget = ash::Shell::GetPrimaryRootWindowController()-> | 370 views::Widget* widget = ash::Shell::GetPrimaryRootWindowController()-> |
371 wallpaper_controller()->widget(); | 371 wallpaper_controller()->widget(); |
372 scoped_ptr<views::MenuRunner> menu_runner( | 372 scoped_ptr<views::MenuRunner> menu_runner( |
373 new views::MenuRunner(menu_model.get())); | 373 new views::MenuRunner(menu_model.get(), views::MenuRunner::CONTEXT_MENU)); |
374 | 374 |
375 // When MenuRunner runs a nested loop the LockScreenAndVerifyMenuClosed | 375 // When MenuRunner runs a nested loop the LockScreenAndVerifyMenuClosed |
376 // command will fire, check the menu state and ensure the nested menu loop | 376 // command will fire, check the menu state and ensure the nested menu loop |
377 // is exited so that the test will terminate. | 377 // is exited so that the test will terminate. |
378 base::MessageLoopForUI::current()->PostTask(FROM_HERE, | 378 base::MessageLoopForUI::current()->PostTask(FROM_HERE, |
379 base::Bind(&ShellTest::LockScreenAndVerifyMenuClosed, | 379 base::Bind(&ShellTest::LockScreenAndVerifyMenuClosed, |
380 base::Unretained(this))); | 380 base::Unretained(this))); |
381 | 381 |
382 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT, | 382 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT, |
383 menu_runner->RunMenuAt(widget, | 383 menu_runner->RunMenuAt(widget, |
384 NULL, | 384 NULL, |
385 gfx::Rect(), | 385 gfx::Rect(), |
386 views::MENU_ANCHOR_TOPLEFT, | 386 views::MENU_ANCHOR_TOPLEFT, |
387 ui::MENU_SOURCE_MOUSE, | 387 ui::MENU_SOURCE_MOUSE)); |
388 views::MenuRunner::CONTEXT_MENU)); | |
389 } | 388 } |
390 | 389 |
391 TEST_F(ShellTest, ManagedWindowModeBasics) { | 390 TEST_F(ShellTest, ManagedWindowModeBasics) { |
392 // We start with the usual window containers. | 391 // We start with the usual window containers. |
393 ExpectAllContainers(); | 392 ExpectAllContainers(); |
394 // Shelf is visible. | 393 // Shelf is visible. |
395 ShelfWidget* shelf_widget = Shelf::ForPrimaryDisplay()->shelf_widget(); | 394 ShelfWidget* shelf_widget = Shelf::ForPrimaryDisplay()->shelf_widget(); |
396 EXPECT_TRUE(shelf_widget->IsVisible()); | 395 EXPECT_TRUE(shelf_widget->IsVisible()); |
397 // Shelf is at bottom-left of screen. | 396 // Shelf is at bottom-left of screen. |
398 EXPECT_EQ(0, shelf_widget->GetWindowBoundsInScreen().x()); | 397 EXPECT_EQ(0, shelf_widget->GetWindowBoundsInScreen().x()); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 private: | 533 private: |
535 DISALLOW_COPY_AND_ASSIGN(ShellTest2); | 534 DISALLOW_COPY_AND_ASSIGN(ShellTest2); |
536 }; | 535 }; |
537 | 536 |
538 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { | 537 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { |
539 window_.reset(new aura::Window(NULL)); | 538 window_.reset(new aura::Window(NULL)); |
540 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 539 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
541 } | 540 } |
542 | 541 |
543 } // namespace ash | 542 } // namespace ash |
OLD | NEW |