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

Unified Diff: ui/views/test/test_views.h

Issue 1254963010: [Views] Move modality tests from widget_unittest.cc to desktop_native_widget_aura_unittest.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/test/test_views.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/test/test_views.h
diff --git a/ui/views/test/test_views.h b/ui/views/test/test_views.h
index 8c490dc98381d4457d44ceed851c7f235f8a0848..28cc27600b799c14c47a4444286f74255f380589 100644
--- a/ui/views/test/test_views.h
+++ b/ui/views/test/test_views.h
@@ -75,6 +75,44 @@ class CloseWidgetView : public View {
DISALLOW_COPY_AND_ASSIGN(CloseWidgetView);
};
+// A view that keeps track of the events it receives, optionally consuming them.
+class EventCountView : public View {
+ public:
+ // Whether to call SetHandled() on events as they are received. For some event
+ // types, this will allow EventCountView to receives future events in the
+ // event sequence, such as a drag.
+ enum HandleMode { PROPAGATE_EVENTS, CONSUME_EVENTS };
+
+ EventCountView();
+ ~EventCountView() override;
+
+ int GetEventCount(ui::EventType type);
+ void ResetCounts();
+
+ int last_flags() const { return last_flags_; }
+
+ void set_handle_mode(HandleMode handle_mode) { handle_mode_ = handle_mode; }
+
+ protected:
+ // Overridden from View:
+ void OnMouseMoved(const ui::MouseEvent& event) override;
+
+ // Overridden from ui::EventHandler:
+ void OnKeyEvent(ui::KeyEvent* event) override;
+ void OnMouseEvent(ui::MouseEvent* event) override;
+ void OnScrollEvent(ui::ScrollEvent* event) override;
+ void OnGestureEvent(ui::GestureEvent* event) override;
+
+ private:
+ void RecordEvent(ui::Event* event);
+
+ std::map<ui::EventType, int> event_count_;
+ int last_flags_;
+ HandleMode handle_mode_;
+
+ DISALLOW_COPY_AND_ASSIGN(EventCountView);
+};
+
} // namespace views
#endif // UI_VIEWS_TEST_TEST_VIEWS_H_
« no previous file with comments | « no previous file | ui/views/test/test_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698