This source file includes following definitions.
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "ash/accelerators/accelerator_filter.h"
#include "ash/accelerators/accelerator_controller.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/test_screenshot_delegate.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/gfx/rect.h"
namespace ash {
namespace test {
typedef AshTestBase AcceleratorFilterTest;
TEST_F(AcceleratorFilterTest, TestFilterWithoutFocus) {
const TestScreenshotDelegate* delegate = GetScreenshotDelegate();
EXPECT_EQ(0, delegate->handle_take_screenshot_count());
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
generator.PressKey(ui::VKEY_PRINT, 0);
EXPECT_EQ(1, delegate->handle_take_screenshot_count());
generator.ReleaseKey(ui::VKEY_PRINT, 0);
EXPECT_EQ(1, delegate->handle_take_screenshot_count());
}
TEST_F(AcceleratorFilterTest, TestFilterWithFocus) {
aura::test::TestWindowDelegate test_delegate;
scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
&test_delegate,
-1,
gfx::Rect()));
wm::ActivateWindow(window.get());
const TestScreenshotDelegate* delegate = GetScreenshotDelegate();
EXPECT_EQ(0, delegate->handle_take_screenshot_count());
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
generator.PressKey(ui::VKEY_PRINT, 0);
EXPECT_EQ(0, delegate->handle_take_screenshot_count());
generator.ReleaseKey(ui::VKEY_PRINT, 0);
EXPECT_EQ(0, delegate->handle_take_screenshot_count());
window.reset();
}
TEST_F(AcceleratorFilterTest, TestCapsLockMask) {
const TestScreenshotDelegate* delegate = GetScreenshotDelegate();
EXPECT_EQ(0, delegate->handle_take_screenshot_count());
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
generator.PressKey(ui::VKEY_PRINT, 0);
EXPECT_EQ(1, delegate->handle_take_screenshot_count());
generator.ReleaseKey(ui::VKEY_PRINT, 0);
EXPECT_EQ(1, delegate->handle_take_screenshot_count());
generator.PressKey(ui::VKEY_PRINT, ui::EF_CAPS_LOCK_DOWN);
EXPECT_EQ(2, delegate->handle_take_screenshot_count());
generator.ReleaseKey(ui::VKEY_PRINT, ui::EF_CAPS_LOCK_DOWN);
EXPECT_EQ(2, delegate->handle_take_screenshot_count());
}
#if defined(OS_CHROMEOS)
TEST_F(AcceleratorFilterTest, CanConsumeSystemKeys) {
AcceleratorFilter filter;
ui::KeyEvent press_a(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
filter.OnKeyEvent(&press_a);
EXPECT_FALSE(press_a.stopped_propagation());
ui::KeyEvent press_mute(
ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_MUTE, ui::EF_NONE, false);
filter.OnKeyEvent(&press_mute);
EXPECT_TRUE(press_mute.stopped_propagation());
scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(1));
wm::GetWindowState(window.get())->set_can_consume_system_keys(true);
ui::KeyEvent press_volume_up(
ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_UP, ui::EF_NONE, false);
ui::Event::DispatcherApi dispatch_helper(&press_volume_up);
dispatch_helper.set_target(window.get());
filter.OnKeyEvent(&press_volume_up);
EXPECT_FALSE(press_volume_up.stopped_propagation());
scoped_ptr<aura::Window> child(CreateTestWindowInShellWithId(2));
window->AddChild(child.get());
dispatch_helper.set_target(child.get());
filter.OnKeyEvent(&press_volume_up);
EXPECT_FALSE(press_volume_up.stopped_propagation());
}
#endif
}
}