Chromium Code Reviews| Index: ui/views/test/widget_event_generator.h |
| diff --git a/ui/views/test/widget_event_generator.h b/ui/views/test/widget_event_generator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6b2bd9d4795f23ba40d2546996c5da95ff1b27b9 |
| --- /dev/null |
| +++ b/ui/views/test/widget_event_generator.h |
| @@ -0,0 +1,54 @@ |
| +// 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 UI_VIEWS_TEST_WIDGET_EVENT_GENERATOR_H_ |
| +#define UI_VIEWS_TEST_WIDGET_EVENT_GENERATOR_H_ |
| + |
| +#include "base/macros.h" |
| +#include "build/build_config.h" |
| +#include "ui/gfx/native_widget_types.h" |
| + |
| +#if defined(USE_AURA) |
| +#include "ui/aura/test/event_generator.h" |
| +#endif |
| + |
| +#if defined(OS_MACOSX) |
|
Andre
2014/06/17 21:17:56
The typedef below uses #elif, why is it different
tapted
2014/06/18 08:28:06
Done.
|
| +#include "ui/views/test/widget_event_generator_mac.h" |
| +#endif |
| + |
| +namespace views { |
| +class Widget; |
| + |
| +namespace test { |
| + |
| +#if defined(USE_AURA) |
| +typedef aura::test::EventGenerator PlatformEventGenerator; |
| +#elif defined(OS_MACOSX) |
| +typedef WidgetEventGeneratorMac PlatformEventGenerator; |
| +#endif |
| + |
| +// A cross-platform event generator that can dispatch events to a views::Widget |
| +// and will work correctly in a sharded non-interactive unit test. On Aura |
| +// builds, it is simply an aura::test::EventGenerator. On other platforms, |
| +// events are generated and dispatched to the native widget. |
| +class WidgetEventGenerator : public PlatformEventGenerator { |
| + public: |
| + explicit WidgetEventGenerator(Widget* widget); |
| + explicit WidgetEventGenerator(gfx::NativeView context); |
| + WidgetEventGenerator(gfx::NativeView context, |
| + Widget* window_for_initial_location); |
| + |
| + ~WidgetEventGenerator(); |
| + |
| + // Simulate a OS-level destruction of the native widget held by |widget|. |
| + static void SimulateNativeDestroy(Widget* widget); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(WidgetEventGenerator); |
| +}; |
| + |
| +} // namespace test |
| +} // namespace views |
| + |
| +#endif // UI_VIEWS_TEST_WIDGET_EVENT_GENERATOR_H_ |