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

Side by Side Diff: ash/shell_unittest.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 months 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
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 "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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 EXPECT_TRUE(controller->IsScreenLocked()); 344 EXPECT_TRUE(controller->IsScreenLocked());
345 GetSessionControllerClient()->UnlockScreen(); 345 GetSessionControllerClient()->UnlockScreen();
346 EXPECT_FALSE(controller->IsScreenLocked()); 346 EXPECT_FALSE(controller->IsScreenLocked());
347 } 347 }
348 348
349 TEST_F(ShellTest, LockScreenClosesActiveMenu) { 349 TEST_F(ShellTest, LockScreenClosesActiveMenu) {
350 SimpleMenuDelegate menu_delegate; 350 SimpleMenuDelegate menu_delegate;
351 std::unique_ptr<ui::SimpleMenuModel> menu_model( 351 std::unique_ptr<ui::SimpleMenuModel> menu_model(
352 new ui::SimpleMenuModel(&menu_delegate)); 352 new ui::SimpleMenuModel(&menu_delegate));
353 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item")); 353 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item"));
354 views::Widget* widget = WmShell::Get() 354 views::Widget* widget = ShellPort::Get()
355 ->GetPrimaryRootWindow() 355 ->GetPrimaryRootWindow()
356 ->GetRootWindowController() 356 ->GetRootWindowController()
357 ->wallpaper_widget_controller() 357 ->wallpaper_widget_controller()
358 ->widget(); 358 ->widget();
359 std::unique_ptr<views::MenuRunner> menu_runner(new views::MenuRunner( 359 std::unique_ptr<views::MenuRunner> menu_runner(new views::MenuRunner(
360 menu_model.get(), 360 menu_model.get(),
361 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC)); 361 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC));
362 362
363 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT, 363 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT,
364 menu_runner->RunMenuAt(widget, NULL, gfx::Rect(), 364 menu_runner->RunMenuAt(widget, NULL, gfx::Rect(),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); 456 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
457 457
458 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 458 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
459 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); 459 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
460 } 460 }
461 461
462 // Tests that the cursor-filter is ahead of the drag-drop controller in the 462 // Tests that the cursor-filter is ahead of the drag-drop controller in the
463 // pre-target list. 463 // pre-target list.
464 TEST_F(ShellTest, TestPreTargetHandlerOrder) { 464 TEST_F(ShellTest, TestPreTargetHandlerOrder) {
465 // TODO: investigate failure in mash, http://crbug.com/695758. 465 // TODO: investigate failure in mash, http://crbug.com/695758.
466 if (WmShell::Get()->IsRunningInMash()) 466 if (ShellPort::Get()->IsRunningInMash())
467 return; 467 return;
468 468
469 Shell* shell = Shell::Get(); 469 Shell* shell = Shell::Get();
470 ui::EventTargetTestApi test_api(shell); 470 ui::EventTargetTestApi test_api(shell);
471 test::ShellTestApi shell_test_api(shell); 471 test::ShellTestApi shell_test_api(shell);
472 472
473 const ui::EventHandlerList& handlers = test_api.pre_target_handlers(); 473 const ui::EventHandlerList& handlers = test_api.pre_target_handlers();
474 ui::EventHandlerList::const_iterator cursor_filter = 474 ui::EventHandlerList::const_iterator cursor_filter =
475 std::find(handlers.begin(), handlers.end(), shell->mouse_cursor_filter()); 475 std::find(handlers.begin(), handlers.end(), shell->mouse_cursor_filter());
476 ui::EventHandlerList::const_iterator drag_drop = std::find( 476 ui::EventHandlerList::const_iterator drag_drop = std::find(
(...skipping 30 matching lines...) Expand all
507 507
508 private: 508 private:
509 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 509 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
510 }; 510 };
511 511
512 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 512 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
513 // TODO: delete this test when conversion to mash is done. This test isn't 513 // TODO: delete this test when conversion to mash is done. This test isn't
514 // applicable to mash as all windows must be destroyed before ash, that isn't 514 // applicable to mash as all windows must be destroyed before ash, that isn't
515 // the case with classic-ash where embedders can separately create 515 // the case with classic-ash where embedders can separately create
516 // aura::Windows. 516 // aura::Windows.
517 if (WmShell::Get()->IsRunningInMash()) 517 if (ShellPort::Get()->IsRunningInMash())
518 return; 518 return;
519 519
520 window_.reset(new aura::Window(NULL)); 520 window_.reset(new aura::Window(NULL));
521 window_->Init(ui::LAYER_NOT_DRAWN); 521 window_->Init(ui::LAYER_NOT_DRAWN);
522 } 522 }
523 523
524 } // namespace ash 524 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698