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

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

Issue 251193005: Enabled volume buttons when TouchView is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged changes with trunk 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/system/tray/system_tray_delegate.h"
10 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
11 #include "ash/test/display_manager_test_api.h" 12 #include "ash/test/display_manager_test_api.h"
13 #include "ash/test/test_volume_control_delegate.h"
12 #include "ui/aura/test/event_generator.h" 14 #include "ui/aura/test/event_generator.h"
13 #include "ui/events/event_handler.h" 15 #include "ui/events/event_handler.h"
14 #include "ui/gfx/vector3d_f.h" 16 #include "ui/gfx/vector3d_f.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
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // Lid open 90 degrees. 322 // Lid open 90 degrees.
321 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), 323 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f),
322 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); 324 gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
323 325
324 event_generator.PressKey(ui::VKEY_ESCAPE, 0); 326 event_generator.PressKey(ui::VKEY_ESCAPE, 0);
325 event_generator.ReleaseKey(ui::VKEY_ESCAPE, 0); 327 event_generator.ReleaseKey(ui::VKEY_ESCAPE, 0);
326 EXPECT_GT(counter.event_count(), 0u); 328 EXPECT_GT(counter.event_count(), 0u);
327 counter.reset(); 329 counter.reset();
328 } 330 }
329 331
332 // Tests that maximize mode does not block Volume Up & Down events.
333 TEST_F(MaximizeModeControllerTest, AllowsVolumeControl) {
334 aura::Window* root = Shell::GetPrimaryRootWindow();
335 aura::test::EventGenerator event_generator(root, root);
336
337 TestVolumeControlDelegate* volume_delegate =
338 new TestVolumeControlDelegate(true);
339 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
340 scoped_ptr<VolumeControlDelegate>(volume_delegate).Pass());
341
342 // Trigger maximize mode by opening to 270 to begin the test in maximize mode.
343 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f),
344 gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
345 ASSERT_TRUE(IsMaximizeModeStarted());
346
347 // Verify volume down button event is not blocked
348 ASSERT_EQ(0, volume_delegate->handle_volume_down_count());
349 event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0);
350 event_generator.ReleaseKey(ui::VKEY_VOLUME_DOWN, 0);
351 EXPECT_EQ(1, volume_delegate->handle_volume_down_count());
352
353 // Verify volume up event is not blocked
354 ASSERT_EQ(0, volume_delegate->handle_volume_up_count());
355 event_generator.PressKey(ui::VKEY_VOLUME_UP, 0);
356 event_generator.ReleaseKey(ui::VKEY_VOLUME_UP, 0);
357 EXPECT_EQ(1, volume_delegate->handle_volume_up_count());
358 }
359
330 TEST_F(MaximizeModeControllerTest, LaptopTest) { 360 TEST_F(MaximizeModeControllerTest, LaptopTest) {
331 // Feeds in sample accelerometer data and verifies that there are no 361 // Feeds in sample accelerometer data and verifies that there are no
332 // transitions into touchview / maximize mode while shaking the device around 362 // transitions into touchview / maximize mode while shaking the device around
333 // with the hinge at less than 180 degrees. 363 // with the hinge at less than 180 degrees.
334 ASSERT_EQ(0u, kAccelerometerLaptopModeTestDataLength % 6); 364 ASSERT_EQ(0u, kAccelerometerLaptopModeTestDataLength % 6);
335 for (size_t i = 0; i < kAccelerometerLaptopModeTestDataLength / 6; ++i) { 365 for (size_t i = 0; i < kAccelerometerLaptopModeTestDataLength / 6; ++i) {
336 gfx::Vector3dF base(kAccelerometerLaptopModeTestData[i * 6], 366 gfx::Vector3dF base(kAccelerometerLaptopModeTestData[i * 6],
337 kAccelerometerLaptopModeTestData[i * 6 + 1], 367 kAccelerometerLaptopModeTestData[i * 6 + 1],
338 kAccelerometerLaptopModeTestData[i * 6 + 2]); 368 kAccelerometerLaptopModeTestData[i * 6 + 2]);
339 gfx::Vector3dF lid(kAccelerometerLaptopModeTestData[i * 6 + 3], 369 gfx::Vector3dF lid(kAccelerometerLaptopModeTestData[i * 6 + 3],
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 441
412 // Trigger maximize mode by opening to 270. 442 // Trigger maximize mode by opening to 270.
413 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), 443 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f),
414 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); 444 gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
415 ASSERT_TRUE(IsMaximizeModeStarted()); 445 ASSERT_TRUE(IsMaximizeModeStarted());
416 EXPECT_TRUE(maximize_mode_controller()->rotation_locked()); 446 EXPECT_TRUE(maximize_mode_controller()->rotation_locked());
417 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); 447 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
418 } 448 }
419 449
420 } // namespace ash 450 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/test_volume_control_delegate.cc ('k') | ash/wm/maximize_mode/maximize_mode_event_blocker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698