summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorabodenha@google.com <abodenha@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-05 16:44:23 +0000
committerabodenha@google.com <abodenha@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-05 16:44:23 +0000
commit680db8794d3159acfc6354e7a4ce46a6abf4dac4 (patch)
tree0c14ed7b3487a6389b6f194b4b7471c88620736a /ash
parente33b3ef385a10caf1aa2e55e0bd10ea5a419c1fd (diff)
downloadchromium_src-680db8794d3159acfc6354e7a4ce46a6abf4dac4.zip
chromium_src-680db8794d3159acfc6354e7a4ce46a6abf4dac4.tar.gz
chromium_src-680db8794d3159acfc6354e7a4ce46a6abf4dac4.tar.bz2
Revert 268181 "Enabled volume buttons when TouchView is active"
> Enabled volume buttons when TouchView is active > > BUG=364584 > TEST=MaximizeModeControllerTest.AllowsVolumeControl > > Review URL: https://codereview.chromium.org/251193005 TBR=bruthig@chromium.org Review URL: https://codereview.chromium.org/266223003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/accelerators/accelerator_controller_unittest.cc63
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/test/test_volume_control_delegate.cc40
-rw-r--r--ash/test/test_volume_control_delegate.h56
-rw-r--r--ash/wm/maximize_mode/maximize_mode_controller_unittest.cc34
-rw-r--r--ash/wm/maximize_mode/maximize_mode_event_blocker.cc16
6 files changed, 59 insertions, 152 deletions
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index dbdc9e1..93277ea 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "ash/accelerators/accelerator_controller.h"
-
#include "ash/accelerators/accelerator_table.h"
#include "ash/accessibility_delegate.h"
#include "ash/ash_switches.h"
@@ -19,7 +18,6 @@
#include "ash/test/display_manager_test_api.h"
#include "ash/test/test_screenshot_delegate.h"
#include "ash/test/test_shell_delegate.h"
-#include "ash/test/test_volume_control_delegate.h"
#include "ash/volume_control_delegate.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
@@ -71,6 +69,55 @@ class ReleaseAccelerator : public ui::Accelerator {
}
};
+class DummyVolumeControlDelegate : public VolumeControlDelegate {
+ public:
+ explicit DummyVolumeControlDelegate(bool consume)
+ : consume_(consume),
+ handle_volume_mute_count_(0),
+ handle_volume_down_count_(0),
+ handle_volume_up_count_(0) {
+ }
+ virtual ~DummyVolumeControlDelegate() {}
+
+ virtual bool HandleVolumeMute(const ui::Accelerator& accelerator) OVERRIDE {
+ ++handle_volume_mute_count_;
+ last_accelerator_ = accelerator;
+ return consume_;
+ }
+ virtual bool HandleVolumeDown(const ui::Accelerator& accelerator) OVERRIDE {
+ ++handle_volume_down_count_;
+ last_accelerator_ = accelerator;
+ return consume_;
+ }
+ virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE {
+ ++handle_volume_up_count_;
+ last_accelerator_ = accelerator;
+ return consume_;
+ }
+
+ int handle_volume_mute_count() const {
+ return handle_volume_mute_count_;
+ }
+ int handle_volume_down_count() const {
+ return handle_volume_down_count_;
+ }
+ int handle_volume_up_count() const {
+ return handle_volume_up_count_;
+ }
+ const ui::Accelerator& last_accelerator() const {
+ return last_accelerator_;
+ }
+
+ private:
+ const bool consume_;
+ int handle_volume_mute_count_;
+ int handle_volume_down_count_;
+ int handle_volume_up_count_;
+ ui::Accelerator last_accelerator_;
+
+ DISALLOW_COPY_AND_ASSIGN(DummyVolumeControlDelegate);
+};
+
class DummyBrightnessControlDelegate : public BrightnessControlDelegate {
public:
explicit DummyBrightnessControlDelegate(bool consume)
@@ -667,8 +714,8 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE);
{
- TestVolumeControlDelegate* delegate =
- new TestVolumeControlDelegate(false);
+ DummyVolumeControlDelegate* delegate =
+ new DummyVolumeControlDelegate(false);
ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
scoped_ptr<VolumeControlDelegate>(delegate).Pass());
EXPECT_EQ(0, delegate->handle_volume_mute_count());
@@ -685,7 +732,7 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
EXPECT_EQ(volume_up, delegate->last_accelerator());
}
{
- TestVolumeControlDelegate* delegate = new TestVolumeControlDelegate(true);
+ DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true);
ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
scoped_ptr<VolumeControlDelegate>(delegate).Pass());
EXPECT_EQ(0, delegate->handle_volume_mute_count());
@@ -1143,8 +1190,8 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) {
EXPECT_TRUE(ProcessWithContext(volume_mute));
EXPECT_TRUE(ProcessWithContext(volume_down));
EXPECT_TRUE(ProcessWithContext(volume_up));
- TestVolumeControlDelegate* delegate =
- new TestVolumeControlDelegate(false);
+ DummyVolumeControlDelegate* delegate =
+ new DummyVolumeControlDelegate(false);
ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
scoped_ptr<VolumeControlDelegate>(delegate).Pass());
EXPECT_EQ(0, delegate->handle_volume_mute_count());
@@ -1161,7 +1208,7 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) {
EXPECT_EQ(volume_up, delegate->last_accelerator());
}
{
- TestVolumeControlDelegate* delegate = new TestVolumeControlDelegate(true);
+ DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true);
ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
scoped_ptr<VolumeControlDelegate>(delegate).Pass());
EXPECT_EQ(0, delegate->handle_volume_mute_count());
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 66279e8..eedf7a7 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -842,8 +842,6 @@
'test/test_system_tray_delegate.h',
'test/test_user_wallpaper_delegate.cc',
'test/test_user_wallpaper_delegate.h',
- 'test/test_volume_control_delegate.cc',
- 'test/test_volume_control_delegate.h',
'test/ui_controls_factory_ash.cc',
'test/ui_controls_factory_ash.h',
],
diff --git a/ash/test/test_volume_control_delegate.cc b/ash/test/test_volume_control_delegate.cc
deleted file mode 100644
index 7c5cad0..0000000
--- a/ash/test/test_volume_control_delegate.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/test/test_volume_control_delegate.h"
-
-namespace ash {
-
-TestVolumeControlDelegate::TestVolumeControlDelegate(bool consume)
- : consume_(consume),
- handle_volume_mute_count_(0),
- handle_volume_down_count_(0),
- handle_volume_up_count_(0) {
-}
-
-TestVolumeControlDelegate::~TestVolumeControlDelegate() {
-}
-
-bool TestVolumeControlDelegate::HandleVolumeMute(
- const ui::Accelerator& accelerator) {
- ++handle_volume_mute_count_;
- last_accelerator_ = accelerator;
- return consume_;
-}
-
-bool TestVolumeControlDelegate::HandleVolumeDown(
- const ui::Accelerator& accelerator) {
- ++handle_volume_down_count_;
- last_accelerator_ = accelerator;
- return consume_;
-}
-
-bool TestVolumeControlDelegate::HandleVolumeUp(
- const ui::Accelerator& accelerator) {
- ++handle_volume_up_count_;
- last_accelerator_ = accelerator;
- return consume_;
-}
-
-} // namespace ash
diff --git a/ash/test/test_volume_control_delegate.h b/ash/test/test_volume_control_delegate.h
deleted file mode 100644
index 85b3e5d..0000000
--- a/ash/test/test_volume_control_delegate.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_TEST_TEST_VOLUME_CONTROL_DELEGATE_H_
-#define ASH_TEST_TEST_VOLUME_CONTROL_DELEGATE_H_
-
-#include "ash/volume_control_delegate.h"
-#include "ui/base/accelerators/accelerator.h"
-
-namespace ash {
-
-// A simple test double for a VolumeControlDelegate
-// Will count the number of times the HandleVolumeMute, HandleVolumeDown and
-// HandleVolumeUp methods are invoked.
-class TestVolumeControlDelegate : public ash::VolumeControlDelegate {
- public:
- explicit TestVolumeControlDelegate(bool consume);
- virtual ~TestVolumeControlDelegate();
-
- int handle_volume_mute_count() const {
- return handle_volume_mute_count_;
- }
-
- int handle_volume_down_count() const {
- return handle_volume_down_count_;
- }
-
- int handle_volume_up_count() const {
- return handle_volume_up_count_;
- }
-
- const ui::Accelerator& last_accelerator() const {
- return last_accelerator_;
- }
-
- // ash::VolumeControlDelegate:
- virtual bool HandleVolumeMute(const ui::Accelerator& accelerator) OVERRIDE;
- virtual bool HandleVolumeDown(const ui::Accelerator& accelerator) OVERRIDE;
- virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE;
-
- private:
- // Keeps track of the return value that should be used for the methods
- // inherited from VolumeControlDelegate
- bool consume_;
- int handle_volume_mute_count_;
- int handle_volume_down_count_;
- int handle_volume_up_count_;
- ui::Accelerator last_accelerator_;
-
- DISALLOW_COPY_AND_ASSIGN(TestVolumeControlDelegate);
-};
-
-} // namespace ash
-
-#endif // ASH_TEST_TEST_VOLUME_CONTROL_DELEGATE_H_
diff --git a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
index a3ff55d..d619fd5 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
@@ -7,10 +7,8 @@
#include "ash/accelerometer/accelerometer_controller.h"
#include "ash/display/display_manager.h"
#include "ash/shell.h"
-#include "ash/system/tray/system_tray_delegate.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/display_manager_test_api.h"
-#include "ash/test/test_volume_control_delegate.h"
#include "ui/aura/test/event_generator.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/vector3d_f.h"
@@ -150,7 +148,7 @@ TEST_F(MaximizeModeControllerTest, EnterExitThresholds) {
// Tests that when the hinge is nearly vertically aligned, the current state
// persists as the computed angle is highly inaccurate in this orientation.
TEST_F(MaximizeModeControllerTest, HingeAligned) {
- // Laptop in normal orientation lid open 90 degrees.
+ // Laptop in normal orientation lid open 90 degrees.
TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f),
gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
EXPECT_FALSE(IsMaximizeModeStarted());
@@ -311,7 +309,7 @@ TEST_F(MaximizeModeControllerTest, BlocksKeyboard) {
EXPECT_EQ(0u, counter.event_count());
counter.reset();
- // Touch should not be blocked.
+ // Touch should not be blocked.
event_generator.PressTouch();
event_generator.ReleaseTouch();
EXPECT_GT(counter.event_count(), 0u);
@@ -329,34 +327,6 @@ TEST_F(MaximizeModeControllerTest, BlocksKeyboard) {
counter.reset();
}
-// Tests that maximize mode does not block Volume Up & Down events.
-TEST_F(MaximizeModeControllerTest, AllowsVolumeControl) {
- aura::Window* root = Shell::GetPrimaryRootWindow();
- aura::test::EventGenerator event_generator(root, root);
-
- TestVolumeControlDelegate* volume_delegate =
- new TestVolumeControlDelegate(false);
- ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
- scoped_ptr<VolumeControlDelegate>(volume_delegate).Pass());
-
- // Trigger maximize mode by opening to 270 to begin the test in maximize mode.
- TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f),
- gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
- ASSERT_TRUE(IsMaximizeModeStarted());
-
- // Verify volume down button event is not blocked
- ASSERT_EQ(0, volume_delegate->handle_volume_down_count());
- event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0);
- event_generator.ReleaseKey(ui::VKEY_VOLUME_DOWN, 0);
- EXPECT_EQ(1, volume_delegate->handle_volume_down_count());
-
- // Verify volume up event is not blocked
- ASSERT_EQ(0, volume_delegate->handle_volume_up_count());
- event_generator.PressKey(ui::VKEY_VOLUME_UP, 0);
- event_generator.ReleaseKey(ui::VKEY_VOLUME_UP, 0);
- EXPECT_EQ(1, volume_delegate->handle_volume_up_count());
-}
-
TEST_F(MaximizeModeControllerTest, LaptopTest) {
// Feeds in sample accelerometer data and verifies that there are no
// transitions into touchview / maximize mode while shaking the device around
diff --git a/ash/wm/maximize_mode/maximize_mode_event_blocker.cc b/ash/wm/maximize_mode/maximize_mode_event_blocker.cc
index dd9fcde..e283149 100644
--- a/ash/wm/maximize_mode/maximize_mode_event_blocker.cc
+++ b/ash/wm/maximize_mode/maximize_mode_event_blocker.cc
@@ -8,7 +8,6 @@
#include "base/memory/scoped_ptr.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/events/event_targeter.h"
-#include "ui/events/keycodes/keyboard_codes.h"
namespace ash {
@@ -55,19 +54,8 @@ void BlockKeyboardAndTouchpadTargeter::SetDefaultTargeter(
ui::EventTarget* BlockKeyboardAndTouchpadTargeter::FindTargetForEvent(
ui::EventTarget* root,
ui::Event* event) {
- if (event->HasNativeEvent()) {
- if (event->IsMouseEvent())
- return NULL;
- if (event->IsKeyEvent()) {
- // TODO(bruthig): Fix this to block rewritten volume keys
- // (i.e. F9 and F10) from the device's keyboard. https://crbug.com/368669
- ui::KeyEvent* key_event = static_cast<ui::KeyEvent*>(event);
- if (key_event->key_code() != ui::VKEY_VOLUME_DOWN &&
- key_event->key_code() != ui::VKEY_VOLUME_UP) {
- return NULL;
- }
- }
- }
+ if (event->HasNativeEvent() && (event->IsMouseEvent() || event->IsKeyEvent()))
+ return NULL;
return default_targeter_->FindTargetForEvent(root, event);
}