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

Unified Diff: ui/base/user_activity/user_activity_detector_unittest.cc

Issue 1016173002: Revert of Fix for menus blocking user activity detection (Retry). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « ui/base/user_activity/user_activity_detector.cc ('k') | ui/ozone/platform/test/ozone_platform_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/user_activity/user_activity_detector_unittest.cc
diff --git a/ui/base/user_activity/user_activity_detector_unittest.cc b/ui/base/user_activity/user_activity_detector_unittest.cc
index 68d9056c851b901e7a914753d83e567beba826bf..dc4cbae20ce7579ead297d40a46b9c6c1ba455cf 100644
--- a/ui/base/user_activity/user_activity_detector_unittest.cc
+++ b/ui/base/user_activity/user_activity_detector_unittest.cc
@@ -13,7 +13,6 @@
#include "ui/events/event_constants.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
-#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/geometry/point.h"
namespace ui {
@@ -37,22 +36,10 @@
DISALLOW_COPY_AND_ASSIGN(TestUserActivityObserver);
};
-// A test implementation of PlatformEventSource that we can instantiate to make
-// sure that the PlatformEventSource has an instance while in unit tests.
-class TestPlatformEventSource : public ui::PlatformEventSource {
- public:
- TestPlatformEventSource() {}
- ~TestPlatformEventSource() override {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestPlatformEventSource);
-};
-
class UserActivityDetectorTest : public testing::Test {
public:
UserActivityDetectorTest()
- : platform_event_source_(new TestPlatformEventSource),
- detector_(new UserActivityDetector),
+ : detector_(new UserActivityDetector),
observer_(new TestUserActivityObserver) {
detector_->AddObserver(observer_.get());
now_ = base::TimeTicks::Now();
@@ -70,11 +57,6 @@
detector_->set_now_for_test(now_);
}
- void OnEvent(const ui::Event* event) {
- detector_->ProcessReceivedEvent(event);
- }
-
- scoped_ptr<TestPlatformEventSource> platform_event_source_;
scoped_ptr<UserActivityDetector> detector_;
scoped_ptr<TestUserActivityObserver> observer_;
@@ -88,7 +70,7 @@
// events.
TEST_F(UserActivityDetectorTest, Basic) {
ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
- OnEvent(&key_event);
+ detector_->OnKeyEvent(&key_event);
EXPECT_FALSE(key_event.handled());
EXPECT_EQ(now_.ToInternalValue(),
detector_->last_activity_time().ToInternalValue());
@@ -100,7 +82,7 @@
AdvanceTime(advance_delta);
ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
- OnEvent(&mouse_event);
+ detector_->OnMouseEvent(&mouse_event);
EXPECT_FALSE(mouse_event.handled());
EXPECT_EQ(now_.ToInternalValue(),
detector_->last_activity_time().ToInternalValue());
@@ -111,7 +93,7 @@
// Temporarily ignore mouse events when displays are turned on or off.
detector_->OnDisplayPowerChanging();
- OnEvent(&mouse_event);
+ detector_->OnMouseEvent(&mouse_event);
EXPECT_FALSE(mouse_event.handled());
EXPECT_EQ(time_before_ignore.ToInternalValue(),
detector_->last_activity_time().ToInternalValue());
@@ -122,7 +104,7 @@
base::TimeDelta::FromMilliseconds(
UserActivityDetector::kDisplayPowerChangeIgnoreMouseMs);
AdvanceTime(kIgnoreMouseTime / 2);
- OnEvent(&mouse_event);
+ detector_->OnMouseEvent(&mouse_event);
EXPECT_FALSE(mouse_event.handled());
EXPECT_EQ(time_before_ignore.ToInternalValue(),
detector_->last_activity_time().ToInternalValue());
@@ -131,7 +113,7 @@
// After enough time has passed, mouse events should be reported again.
AdvanceTime(std::max(kIgnoreMouseTime, advance_delta));
- OnEvent(&mouse_event);
+ detector_->OnMouseEvent(&mouse_event);
EXPECT_FALSE(mouse_event.handled());
EXPECT_EQ(now_.ToInternalValue(),
detector_->last_activity_time().ToInternalValue());
@@ -141,7 +123,7 @@
AdvanceTime(advance_delta);
ui::TouchEvent touch_event(
ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta());
- OnEvent(&touch_event);
+ detector_->OnTouchEvent(&touch_event);
EXPECT_FALSE(touch_event.handled());
EXPECT_EQ(now_.ToInternalValue(),
detector_->last_activity_time().ToInternalValue());
@@ -155,7 +137,7 @@
ui::EF_NONE,
base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000),
ui::GestureEventDetails(ui::ET_GESTURE_TAP));
- OnEvent(&gesture_event);
+ detector_->OnGestureEvent(&gesture_event);
EXPECT_FALSE(gesture_event.handled());
EXPECT_EQ(now_.ToInternalValue(),
detector_->last_activity_time().ToInternalValue());
@@ -167,14 +149,14 @@
TEST_F(UserActivityDetectorTest, RateLimitNotifications) {
// The observer should be notified about a key event.
ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
- OnEvent(&event);
+ detector_->OnKeyEvent(&event);
EXPECT_FALSE(event.handled());
EXPECT_EQ(1, observer_->num_invocations());
observer_->reset_stats();
// It shouldn't be notified if a second event occurs in the same instant in
// time.
- OnEvent(&event);
+ detector_->OnKeyEvent(&event);
EXPECT_FALSE(event.handled());
EXPECT_EQ(0, observer_->num_invocations());
observer_->reset_stats();
@@ -183,7 +165,7 @@
AdvanceTime(
base::TimeDelta::FromMilliseconds(
UserActivityDetector::kNotifyIntervalMs - 100));
- OnEvent(&event);
+ detector_->OnKeyEvent(&event);
EXPECT_FALSE(event.handled());
EXPECT_EQ(0, observer_->num_invocations());
observer_->reset_stats();
@@ -193,7 +175,7 @@
AdvanceTime(base::TimeDelta::FromMilliseconds(
UserActivityDetector::kNotifyIntervalMs));
- OnEvent(&event);
+ detector_->OnKeyEvent(&event);
EXPECT_FALSE(event.handled());
EXPECT_EQ(1, observer_->num_invocations());
}
@@ -203,7 +185,7 @@
ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED,
ui::EF_NONE);
- OnEvent(&mouse_event);
+ detector_->OnMouseEvent(&mouse_event);
EXPECT_FALSE(mouse_event.handled());
EXPECT_EQ(base::TimeTicks().ToInternalValue(),
detector_->last_activity_time().ToInternalValue());
« no previous file with comments | « ui/base/user_activity/user_activity_detector.cc ('k') | ui/ozone/platform/test/ozone_platform_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698