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

Side by Side Diff: ash/shell_unittest.cc

Issue 16463002: Change ordering of Shell event handlers: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « ash/shell.cc ('k') | ash/test/shell_test_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
13 #include "ash/drag_drop/drag_drop_controller.h"
12 #include "ash/launcher/launcher.h" 14 #include "ash/launcher/launcher.h"
13 #include "ash/root_window_controller.h" 15 #include "ash/root_window_controller.h"
14 #include "ash/session_state_delegate.h" 16 #include "ash/session_state_delegate.h"
15 #include "ash/shelf/shelf_layout_manager.h" 17 #include "ash/shelf/shelf_layout_manager.h"
16 #include "ash/shelf/shelf_widget.h" 18 #include "ash/shelf/shelf_widget.h"
17 #include "ash/shell_window_ids.h" 19 #include "ash/shell_window_ids.h"
18 #include "ash/test/ash_test_base.h" 20 #include "ash/test/ash_test_base.h"
21 #include "ash/test/shell_test_api.h"
19 #include "ash/wm/root_window_layout_manager.h" 22 #include "ash/wm/root_window_layout_manager.h"
20 #include "ash/wm/window_util.h" 23 #include "ash/wm/window_util.h"
21 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
22 #include "ui/aura/client/aura_constants.h" 25 #include "ui/aura/client/aura_constants.h"
23 #include "ui/aura/root_window.h" 26 #include "ui/aura/root_window.h"
24 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
25 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
26 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
27 #include "ui/views/widget/widget_delegate.h" 30 #include "ui/views/widget/widget_delegate.h"
28 #include "ui/views/window/dialog_delegate.h" 31 #include "ui/views/window/dialog_delegate.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 419 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
417 root_window); 420 root_window);
418 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 421 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
419 shell->GetShelfAutoHideBehavior(root_window)); 422 shell->GetShelfAutoHideBehavior(root_window));
420 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, 423 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
421 root_window); 424 root_window);
422 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, 425 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
423 shell->GetShelfAutoHideBehavior(root_window)); 426 shell->GetShelfAutoHideBehavior(root_window));
424 } 427 }
425 428
429 TEST_F(ShellTest, TestPreTargetHandlerOrder) {
430 Shell* shell = Shell::GetInstance();
431 Shell::TestApi test_api(shell);
432 test::ShellTestApi shell_test_api(shell);
433
434 const ui::EventHandlerList& handlers = test_api.pre_target_handlers();
435 EXPECT_EQ(handlers[0], shell->mouse_cursor_filter());
436 EXPECT_EQ(handlers[1], shell_test_api.drag_drop_controller());
437 }
438
426 // This verifies WindowObservers are removed when a window is destroyed after 439 // This verifies WindowObservers are removed when a window is destroyed after
427 // the Shell is destroyed. This scenario (aura::Windows being deleted after the 440 // the Shell is destroyed. This scenario (aura::Windows being deleted after the
428 // Shell) occurs if someone is holding a reference to an unparented Window, as 441 // Shell) occurs if someone is holding a reference to an unparented Window, as
429 // is the case with a RenderWidgetHostViewAura that isn't on screen. As long as 442 // is the case with a RenderWidgetHostViewAura that isn't on screen. As long as
430 // everything is ok, we won't crash. If there is a bug, window's destructor will 443 // everything is ok, we won't crash. If there is a bug, window's destructor will
431 // notify some deleted object (say VideoDetector or ActivationController) and 444 // notify some deleted object (say VideoDetector or ActivationController) and
432 // this will crash. 445 // this will crash.
433 class ShellTest2 : public test::AshTestBase { 446 class ShellTest2 : public test::AshTestBase {
434 public: 447 public:
435 ShellTest2() {} 448 ShellTest2() {}
436 virtual ~ShellTest2() {} 449 virtual ~ShellTest2() {}
437 450
438 protected: 451 protected:
439 scoped_ptr<aura::Window> window_; 452 scoped_ptr<aura::Window> window_;
440 453
441 private: 454 private:
442 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 455 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
443 }; 456 };
444 457
445 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 458 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
446 window_.reset(new aura::Window(NULL)); 459 window_.reset(new aura::Window(NULL));
447 window_->Init(ui::LAYER_NOT_DRAWN); 460 window_->Init(ui::LAYER_NOT_DRAWN);
448 } 461 }
449 462
450 } // namespace ash 463 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | ash/test/shell_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698