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

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 1 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 TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) {
flackr 2014/05/05 20:26:54 nit: Add a comment line before this to say what th
bruthig 2014/05/05 20:57:22 Done.
422 test::TestSystemTrayDelegate* tray_delegate =
423 static_cast<test::TestSystemTrayDelegate*>(
424 Shell::GetInstance()->system_tray_delegate());
425 tray_delegate->set_should_show_display_notification(true);
426
427 aura::Window* root = Shell::GetPrimaryRootWindow();
428 aura::test::EventGenerator event_generator(root, root);
429 message_center::MessageCenter* message_center =
430 message_center::MessageCenter::Get();
flackr 2014/05/05 20:26:54 nit: indent 4.
bruthig 2014/05/05 20:57:22 Done.
431
432 DisplayManager* display_manager =
433 Shell::GetInstance()->display_manager();
434
435 // Make sure notifications are still displayed when
436 // adjusting the screen rotation directly
flackr 2014/05/05 20:26:54 nit: Punctuation.
bruthig 2014/05/05 20:57:22 Done.
437 ASSERT_EQ(0u, message_center->NotificationCount());
438 ASSERT_EQ(gfx::Display::ROTATE_0, display_manager->GetDisplayInfo(
439 gfx::Display::InternalDisplayId()).rotation());
440 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
441 gfx::Display::ROTATE_90);
442 ASSERT_EQ(1u, message_center->NotificationCount());
443 message_center->RemoveAllNotifications(false);
444 ASSERT_EQ(0u, message_center->NotificationCount());
445
446 //
flackr 2014/05/05 20:26:54 nit: Remove empty comment line.
bruthig 2014/05/05 20:57:22 Done.
447 // Trigger maximize mode by opening to 270.
448 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f),
449 gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
450 // Rotate to 90 degrees
451 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f),
452 gfx::Vector3dF(0.0f, 1.0f, 0.0f));
453 EXPECT_EQ(0u, message_center->NotificationCount());
454 }
455
419 } // namespace ash 456 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698