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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc

Issue 267743010: Suppressed screen rotation notifications triggeres by the accelerometer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Rob's comments from patch set 2 Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/wm/maximize_mode/maximize_mode_controller.h" 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
6 6
7 #include "ash/accelerometer/accelerometer_controller.h" 7 #include "ash/accelerometer/accelerometer_controller.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/display_manager_test_api.h" 11 #include "ash/test/display_manager_test_api.h"
12 #include "ash/test/test_system_tray_delegate.h"
12 #include "ui/aura/test/event_generator.h" 13 #include "ui/aura/test/event_generator.h"
13 #include "ui/events/event_handler.h" 14 #include "ui/events/event_handler.h"
14 #include "ui/gfx/vector3d_f.h" 15 #include "ui/gfx/vector3d_f.h"
16 #include "ui/message_center/message_center.h"
15 17
16 namespace ash { 18 namespace ash {
17 19
18 namespace { 20 namespace {
19 21
20 const float kDegreesToRadians = 3.14159265f / 180.0f; 22 const float kDegreesToRadians = 3.14159265f / 180.0f;
21 23
22 // Filter to count the number of events seen. 24 // Filter to count the number of events seen.
23 class EventCounter : public ui::EventHandler { 25 class EventCounter : public ui::EventHandler {
24 public: 26 public:
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 411
410 // Open 90 degrees. 412 // Open 90 degrees.
411 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); 413 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
412 EXPECT_FALSE(IsMaximizeModeStarted()); 414 EXPECT_FALSE(IsMaximizeModeStarted());
413 415
414 // Send an update that would not relaunch MaximizeMode. 90 degrees. 416 // Send an update that would not relaunch MaximizeMode. 90 degrees.
415 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); 417 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
416 EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); 418 EXPECT_FALSE(maximize_mode_controller()->rotation_locked());
417 } 419 }
418 420
421 // Tests that the screen rotation notifications are suppressed when
422 // triggered by the accelerometer.
423 TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) {
424 test::TestSystemTrayDelegate* tray_delegate =
425 static_cast<test::TestSystemTrayDelegate*>(
426 Shell::GetInstance()->system_tray_delegate());
427 tray_delegate->set_should_show_display_notification(true);
428
429 aura::Window* root = Shell::GetPrimaryRootWindow();
430 aura::test::EventGenerator event_generator(root, root);
431 message_center::MessageCenter* message_center =
432 message_center::MessageCenter::Get();
433
434 DisplayManager* display_manager =
435 Shell::GetInstance()->display_manager();
436
437 // Make sure notifications are still displayed when
438 // adjusting the screen rotation directly.
439 ASSERT_EQ(0u, message_center->NotificationCount());
440 ASSERT_EQ(gfx::Display::ROTATE_0, display_manager->GetDisplayInfo(
441 gfx::Display::InternalDisplayId()).rotation());
442 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
443 gfx::Display::ROTATE_90);
444 ASSERT_EQ(1u, message_center->NotificationCount());
445 message_center->RemoveAllNotifications(false);
446 ASSERT_EQ(0u, message_center->NotificationCount());
447
448 // Trigger maximize mode by opening to 270.
449 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f),
450 gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
451 // Rotate to 90 degrees
452 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f),
453 gfx::Vector3dF(0.0f, 1.0f, 0.0f));
454 EXPECT_EQ(0u, message_center->NotificationCount());
455 }
456
419 } // namespace ash 457 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698