| 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/display/mouse_cursor_event_filter.h" | 10 #include "ash/display/mouse_cursor_event_filter.h" |
| 11 #include "ash/drag_drop/drag_drop_controller.h" | 11 #include "ash/drag_drop/drag_drop_controller.h" |
| 12 #include "ash/public/cpp/shell_window_ids.h" | 12 #include "ash/public/cpp/shell_window_ids.h" |
| 13 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 14 #include "ash/session/session_controller.h" | 14 #include "ash/session/session_controller.h" |
| 15 #include "ash/shelf/shelf_layout_manager.h" | 15 #include "ash/shelf/shelf_layout_manager.h" |
| 16 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
| 17 #include "ash/shelf/wm_shelf.h" | 17 #include "ash/shelf/wm_shelf.h" |
| 18 #include "ash/shell_port.h" |
| 18 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
| 19 #include "ash/test/shell_test_api.h" | 20 #include "ash/test/shell_test_api.h" |
| 20 #include "ash/test/test_session_controller_client.h" | 21 #include "ash/test/test_session_controller_client.h" |
| 21 #include "ash/wallpaper/wallpaper_widget_controller.h" | 22 #include "ash/wallpaper/wallpaper_widget_controller.h" |
| 22 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
| 23 #include "ash/wm_shell.h" | |
| 24 #include "ash/wm_window.h" | 24 #include "ash/wm_window.h" |
| 25 #include "base/macros.h" | 25 #include "base/macros.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "ui/aura/client/aura_constants.h" | 28 #include "ui/aura/client/aura_constants.h" |
| 29 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
| 30 #include "ui/aura/window.h" | 30 #include "ui/aura/window.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 31 #include "ui/aura/window_event_dispatcher.h" |
| 32 #include "ui/base/models/simple_menu_model.h" | 32 #include "ui/base/models/simple_menu_model.h" |
| 33 #include "ui/events/test/event_generator.h" | 33 #include "ui/events/test/event_generator.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 EXPECT_TRUE(controller->IsScreenLocked()); | 340 EXPECT_TRUE(controller->IsScreenLocked()); |
| 341 GetSessionControllerClient()->UnlockScreen(); | 341 GetSessionControllerClient()->UnlockScreen(); |
| 342 EXPECT_FALSE(controller->IsScreenLocked()); | 342 EXPECT_FALSE(controller->IsScreenLocked()); |
| 343 } | 343 } |
| 344 | 344 |
| 345 TEST_F(ShellTest, LockScreenClosesActiveMenu) { | 345 TEST_F(ShellTest, LockScreenClosesActiveMenu) { |
| 346 SimpleMenuDelegate menu_delegate; | 346 SimpleMenuDelegate menu_delegate; |
| 347 std::unique_ptr<ui::SimpleMenuModel> menu_model( | 347 std::unique_ptr<ui::SimpleMenuModel> menu_model( |
| 348 new ui::SimpleMenuModel(&menu_delegate)); | 348 new ui::SimpleMenuModel(&menu_delegate)); |
| 349 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item")); | 349 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item")); |
| 350 views::Widget* widget = WmShell::Get() | 350 views::Widget* widget = ShellPort::Get() |
| 351 ->GetPrimaryRootWindow() | 351 ->GetPrimaryRootWindow() |
| 352 ->GetRootWindowController() | 352 ->GetRootWindowController() |
| 353 ->wallpaper_widget_controller() | 353 ->wallpaper_widget_controller() |
| 354 ->widget(); | 354 ->widget(); |
| 355 std::unique_ptr<views::MenuRunner> menu_runner(new views::MenuRunner( | 355 std::unique_ptr<views::MenuRunner> menu_runner(new views::MenuRunner( |
| 356 menu_model.get(), | 356 menu_model.get(), |
| 357 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC)); | 357 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC)); |
| 358 | 358 |
| 359 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT, | 359 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT, |
| 360 menu_runner->RunMenuAt(widget, NULL, gfx::Rect(), | 360 menu_runner->RunMenuAt(widget, NULL, gfx::Rect(), |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 452 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 453 | 453 |
| 454 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 454 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 455 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 455 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 456 } | 456 } |
| 457 | 457 |
| 458 // Tests that the cursor-filter is ahead of the drag-drop controller in the | 458 // Tests that the cursor-filter is ahead of the drag-drop controller in the |
| 459 // pre-target list. | 459 // pre-target list. |
| 460 TEST_F(ShellTest, TestPreTargetHandlerOrder) { | 460 TEST_F(ShellTest, TestPreTargetHandlerOrder) { |
| 461 // TODO: investigate failure in mash, http://crbug.com/695758. | 461 // TODO: investigate failure in mash, http://crbug.com/695758. |
| 462 if (WmShell::Get()->IsRunningInMash()) | 462 if (ShellPort::Get()->IsRunningInMash()) |
| 463 return; | 463 return; |
| 464 | 464 |
| 465 Shell* shell = Shell::Get(); | 465 Shell* shell = Shell::Get(); |
| 466 ui::EventTargetTestApi test_api(shell); | 466 ui::EventTargetTestApi test_api(shell); |
| 467 test::ShellTestApi shell_test_api(shell); | 467 test::ShellTestApi shell_test_api(shell); |
| 468 | 468 |
| 469 const ui::EventHandlerList& handlers = test_api.pre_target_handlers(); | 469 const ui::EventHandlerList& handlers = test_api.pre_target_handlers(); |
| 470 ui::EventHandlerList::const_iterator cursor_filter = | 470 ui::EventHandlerList::const_iterator cursor_filter = |
| 471 std::find(handlers.begin(), handlers.end(), shell->mouse_cursor_filter()); | 471 std::find(handlers.begin(), handlers.end(), shell->mouse_cursor_filter()); |
| 472 ui::EventHandlerList::const_iterator drag_drop = std::find( | 472 ui::EventHandlerList::const_iterator drag_drop = std::find( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 503 | 503 |
| 504 private: | 504 private: |
| 505 DISALLOW_COPY_AND_ASSIGN(ShellTest2); | 505 DISALLOW_COPY_AND_ASSIGN(ShellTest2); |
| 506 }; | 506 }; |
| 507 | 507 |
| 508 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { | 508 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { |
| 509 // TODO: delete this test when conversion to mash is done. This test isn't | 509 // TODO: delete this test when conversion to mash is done. This test isn't |
| 510 // applicable to mash as all windows must be destroyed before ash, that isn't | 510 // applicable to mash as all windows must be destroyed before ash, that isn't |
| 511 // the case with classic-ash where embedders can separately create | 511 // the case with classic-ash where embedders can separately create |
| 512 // aura::Windows. | 512 // aura::Windows. |
| 513 if (WmShell::Get()->IsRunningInMash()) | 513 if (ShellPort::Get()->IsRunningInMash()) |
| 514 return; | 514 return; |
| 515 | 515 |
| 516 window_.reset(new aura::Window(NULL)); | 516 window_.reset(new aura::Window(NULL)); |
| 517 window_->Init(ui::LAYER_NOT_DRAWN); | 517 window_->Init(ui::LAYER_NOT_DRAWN); |
| 518 } | 518 } |
| 519 | 519 |
| 520 } // namespace ash | 520 } // namespace ash |
| OLD | NEW |