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

Side by Side Diff: ash/shell_unittest.cc

Issue 206593004: Move TestEventHandler to ui/events/test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | 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 "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"
11 #include "ash/desktop_background/desktop_background_widget_controller.h" 11 #include "ash/desktop_background/desktop_background_widget_controller.h"
12 #include "ash/display/mouse_cursor_event_filter.h" 12 #include "ash/display/mouse_cursor_event_filter.h"
13 #include "ash/drag_drop/drag_drop_controller.h" 13 #include "ash/drag_drop/drag_drop_controller.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/session_state_delegate.h" 15 #include "ash/session_state_delegate.h"
16 #include "ash/shelf/shelf.h" 16 #include "ash/shelf/shelf.h"
17 #include "ash/shelf/shelf_layout_manager.h" 17 #include "ash/shelf/shelf_layout_manager.h"
18 #include "ash/shelf/shelf_widget.h" 18 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shell_delegate.h" 19 #include "ash/shell_delegate.h"
20 #include "ash/shell_window_ids.h" 20 #include "ash/shell_window_ids.h"
21 #include "ash/test/ash_test_base.h" 21 #include "ash/test/ash_test_base.h"
22 #include "ash/test/shell_test_api.h" 22 #include "ash/test/shell_test_api.h"
23 #include "ash/wm/root_window_layout_manager.h" 23 #include "ash/wm/root_window_layout_manager.h"
24 #include "ash/wm/window_util.h" 24 #include "ash/wm/window_util.h"
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "ui/aura/client/aura_constants.h" 26 #include "ui/aura/client/aura_constants.h"
27 #include "ui/aura/env.h" 27 #include "ui/aura/env.h"
28 #include "ui/aura/test/event_generator.h" 28 #include "ui/aura/test/event_generator.h"
29 #include "ui/aura/test/test_event_handler.h"
30 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
31 #include "ui/aura/window_event_dispatcher.h" 30 #include "ui/aura/window_event_dispatcher.h"
32 #include "ui/base/models/simple_menu_model.h" 31 #include "ui/base/models/simple_menu_model.h"
33 #include "ui/events/test/events_test_utils.h" 32 #include "ui/events/test/events_test_utils.h"
33 #include "ui/events/test/test_event_handler.h"
34 #include "ui/gfx/size.h" 34 #include "ui/gfx/size.h"
35 #include "ui/views/controls/menu/menu_controller.h" 35 #include "ui/views/controls/menu/menu_controller.h"
36 #include "ui/views/controls/menu/menu_runner.h" 36 #include "ui/views/controls/menu/menu_runner.h"
37 #include "ui/views/widget/widget.h" 37 #include "ui/views/widget/widget.h"
38 #include "ui/views/widget/widget_delegate.h" 38 #include "ui/views/widget/widget_delegate.h"
39 #include "ui/views/window/dialog_delegate.h" 39 #include "ui/views/window/dialog_delegate.h"
40 40
41 using aura::RootWindow; 41 using aura::RootWindow;
42 42
43 namespace ash { 43 namespace ash {
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 ui::EventHandlerList::const_iterator drag_drop = 509 ui::EventHandlerList::const_iterator drag_drop =
510 std::find(handlers.begin(), handlers.end(), 510 std::find(handlers.begin(), handlers.end(),
511 shell_test_api.drag_drop_controller()); 511 shell_test_api.drag_drop_controller());
512 EXPECT_NE(handlers.end(), cursor_filter); 512 EXPECT_NE(handlers.end(), cursor_filter);
513 EXPECT_NE(handlers.end(), drag_drop); 513 EXPECT_NE(handlers.end(), drag_drop);
514 EXPECT_GT(drag_drop, cursor_filter); 514 EXPECT_GT(drag_drop, cursor_filter);
515 } 515 }
516 516
517 // Verifies an EventHandler added to Env gets notified from EventGenerator. 517 // Verifies an EventHandler added to Env gets notified from EventGenerator.
518 TEST_F(ShellTest, EnvPreTargetHandler) { 518 TEST_F(ShellTest, EnvPreTargetHandler) {
519 aura::test::TestEventHandler event_handler; 519 ui::test::TestEventHandler event_handler;
520 aura::Env::GetInstance()->AddPreTargetHandler(&event_handler); 520 aura::Env::GetInstance()->AddPreTargetHandler(&event_handler);
521 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 521 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
522 generator.MoveMouseBy(1, 1); 522 generator.MoveMouseBy(1, 1);
523 EXPECT_NE(0, event_handler.num_mouse_events()); 523 EXPECT_NE(0, event_handler.num_mouse_events());
524 aura::Env::GetInstance()->RemovePreTargetHandler(&event_handler); 524 aura::Env::GetInstance()->RemovePreTargetHandler(&event_handler);
525 } 525 }
526 526
527 // This verifies WindowObservers are removed when a window is destroyed after 527 // This verifies WindowObservers are removed when a window is destroyed after
528 // the Shell is destroyed. This scenario (aura::Windows being deleted after the 528 // the Shell is destroyed. This scenario (aura::Windows being deleted after the
529 // Shell) occurs if someone is holding a reference to an unparented Window, as 529 // Shell) occurs if someone is holding a reference to an unparented Window, as
(...skipping 12 matching lines...) Expand all
542 private: 542 private:
543 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 543 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
544 }; 544 };
545 545
546 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 546 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
547 window_.reset(new aura::Window(NULL)); 547 window_.reset(new aura::Window(NULL));
548 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); 548 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
549 } 549 }
550 550
551 } // namespace ash 551 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller_unittest.cc ('k') | ash/wm/immersive_fullscreen_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698