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

Side by Side Diff: ash/shell_unittest.cc

Issue 1640503002: ash: Do not use MessageLoopForUI when not needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/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/session_state_delegate.h" 15 #include "ash/session/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 "base/thread_task_runner_handle.h"
26 #include "ui/aura/client/aura_constants.h" 27 #include "ui/aura/client/aura_constants.h"
27 #include "ui/aura/env.h" 28 #include "ui/aura/env.h"
28 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
29 #include "ui/aura/window_event_dispatcher.h" 30 #include "ui/aura/window_event_dispatcher.h"
30 #include "ui/base/models/simple_menu_model.h" 31 #include "ui/base/models/simple_menu_model.h"
31 #include "ui/events/test/event_generator.h" 32 #include "ui/events/test/event_generator.h"
32 #include "ui/events/test/events_test_utils.h" 33 #include "ui/events/test/events_test_utils.h"
33 #include "ui/events/test/test_event_handler.h" 34 #include "ui/events/test/test_event_handler.h"
34 #include "ui/gfx/geometry/size.h" 35 #include "ui/gfx/geometry/size.h"
35 #include "ui/views/controls/menu/menu_controller.h" 36 #include "ui/views/controls/menu/menu_controller.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 new ui::SimpleMenuModel(&menu_delegate)); 355 new ui::SimpleMenuModel(&menu_delegate));
355 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item")); 356 menu_model->AddItem(0, base::ASCIIToUTF16("Menu item"));
356 views::Widget* widget = ash::Shell::GetPrimaryRootWindowController()-> 357 views::Widget* widget = ash::Shell::GetPrimaryRootWindowController()->
357 wallpaper_controller()->widget(); 358 wallpaper_controller()->widget();
358 scoped_ptr<views::MenuRunner> menu_runner( 359 scoped_ptr<views::MenuRunner> menu_runner(
359 new views::MenuRunner(menu_model.get(), views::MenuRunner::CONTEXT_MENU)); 360 new views::MenuRunner(menu_model.get(), views::MenuRunner::CONTEXT_MENU));
360 361
361 // When MenuRunner runs a nested loop the LockScreenAndVerifyMenuClosed 362 // When MenuRunner runs a nested loop the LockScreenAndVerifyMenuClosed
362 // command will fire, check the menu state and ensure the nested menu loop 363 // command will fire, check the menu state and ensure the nested menu loop
363 // is exited so that the test will terminate. 364 // is exited so that the test will terminate.
364 base::MessageLoopForUI::current()->PostTask(FROM_HERE, 365 base::ThreadTaskRunnerHandle::Get()->PostTask(
365 base::Bind(&ShellTest::LockScreenAndVerifyMenuClosed, 366 FROM_HERE, base::Bind(&ShellTest::LockScreenAndVerifyMenuClosed,
366 base::Unretained(this))); 367 base::Unretained(this)));
367 368
368 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT, 369 EXPECT_EQ(views::MenuRunner::NORMAL_EXIT,
369 menu_runner->RunMenuAt(widget, 370 menu_runner->RunMenuAt(widget,
370 NULL, 371 NULL,
371 gfx::Rect(), 372 gfx::Rect(),
372 views::MENU_ANCHOR_TOPLEFT, 373 views::MENU_ANCHOR_TOPLEFT,
373 ui::MENU_SOURCE_MOUSE)); 374 ui::MENU_SOURCE_MOUSE));
374 } 375 }
375 376
376 TEST_F(ShellTest, ManagedWindowModeBasics) { 377 TEST_F(ShellTest, ManagedWindowModeBasics) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 private: 523 private:
523 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 524 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
524 }; 525 };
525 526
526 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 527 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
527 window_.reset(new aura::Window(NULL)); 528 window_.reset(new aura::Window(NULL));
528 window_->Init(ui::LAYER_NOT_DRAWN); 529 window_->Init(ui::LAYER_NOT_DRAWN);
529 } 530 }
530 531
531 } // namespace ash 532 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698