Chromium Code Reviews| Index: ui/events/test/device_data_manager_test_api.cc |
| diff --git a/ui/events/test/device_data_manager_test_api.cc b/ui/events/test/device_data_manager_test_api.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..200a03a2d71eb38e0f210e793a1baa83c4e413ef |
| --- /dev/null |
| +++ b/ui/events/test/device_data_manager_test_api.cc |
| @@ -0,0 +1,96 @@ |
| +// Copyright 2015 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 "ui/events/test/device_data_manager_test_api.h" |
| + |
| +#define DEVICE_DATA_MANAGER_IS_AVAILABLE \ |
| + (defined(USE_OZONE) || defined(USE_X11)) |
| + |
| +#if DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +#include "ui/events/devices/device_data_manager.h" |
| +#endif // DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + |
| +namespace ui { |
| +namespace test { |
| + |
| +DeviceDataManagerTestAPI::DeviceDataManagerTestAPI() { |
| +} |
| + |
| +DeviceDataManagerTestAPI::~DeviceDataManagerTestAPI() { |
| +#if !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + NOTREACHED(); |
| +#else |
| + if (DeviceDataManager::instance() == device_data_manager_.get()) |
| + DeviceDataManager::set_instance(nullptr); |
| +#endif // !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +} |
| + |
| +bool DeviceDataManagerTestAPI::CreateDeviceDataManagerInstance() { |
| +#if !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + return false; |
| +#else |
| + if (DeviceDataManager::instance()) |
| + DeviceDataManager::set_instance(nullptr); |
| + |
| + device_data_manager_.reset(new DeviceDataManager()); |
| + DeviceDataManager::set_instance(device_data_manager_.get()); |
| + |
| + return true; |
| +#endif // !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +} |
| + |
| +void DeviceDataManagerTestAPI:: |
| + NotifyObserversTouchscreenDeviceConfigurationChanged() { |
| +#if !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + NOTREACHED(); |
| +#else |
| + device_data_manager_->NotifyObserversTouchscreenDeviceConfigurationChanged(); |
| +#endif // !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +} |
| + |
| +void DeviceDataManagerTestAPI:: |
| + NotifyObserversKeyboardDeviceConfigurationChanged() { |
| +#if !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + NOTREACHED(); |
| +#else |
| + device_data_manager_->NotifyObserversKeyboardDeviceConfigurationChanged(); |
| +#endif // !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +} |
| + |
| +void DeviceDataManagerTestAPI:: |
| + NotifyObserversMouseDeviceConfigurationChanged() { |
| +#if !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + NOTREACHED(); |
| +#else |
| + device_data_manager_->NotifyObserversMouseDeviceConfigurationChanged(); |
| +#endif // !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +} |
| + |
| +void DeviceDataManagerTestAPI:: |
| + NotifyObserversTouchpadDeviceConfigurationChanged() { |
| +#if !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + NOTREACHED(); |
| +#else |
| + device_data_manager_->NotifyObserversTouchpadDeviceConfigurationChanged(); |
| +#endif // !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +} |
| + |
| +void DeviceDataManagerTestAPI::NotifyObserversDeviceListsComplete() { |
| +#if !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + NOTREACHED(); |
| +#else |
| + device_data_manager_->NotifyObserversDeviceListsComplete(); |
| +#endif // !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +} |
| + |
| +void DeviceDataManagerTestAPI::OnDeviceListsComplete() { |
| +#if !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| + NOTREACHED(); |
| +#else |
| + device_data_manager_->OnDeviceListsComplete(); |
| +#endif // !DEVICE_DATA_MANAGER_IS_AVAILABLE |
| +} |
| + |
|
sadrul
2015/07/10 17:35:48
Split this into two files: device_data_manager_tes
bruthig
2015/07/10 20:04:58
Done.
|
| +} // namespace test |
| +} // namespace ui |