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

Unified Diff: chrome/browser/extensions/api/idle/idle_api_unittest.cc

Issue 251173003: Don't fire idle active event when listener re-added (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self nit Created 6 years, 8 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 | chrome/browser/extensions/api/idle/idle_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/idle/idle_api_unittest.cc
diff --git a/chrome/browser/extensions/api/idle/idle_api_unittest.cc b/chrome/browser/extensions/api/idle/idle_api_unittest.cc
index 62a313384ebb4a5b948d53dc8633aaf7833f56a8..83c03cb54afd79f5ebad2fb5d447aec1267b9797 100644
--- a/chrome/browser/extensions/api/idle/idle_api_unittest.cc
+++ b/chrome/browser/extensions/api/idle/idle_api_unittest.cc
@@ -550,4 +550,30 @@ TEST_F(IdleTest, UnloadWhileListening) {
content::Details<UnloadedExtensionInfo>(&details));
}
+// Verifies that re-adding a listener after a state change doesn't immediately
+// fire a change event. Regression test for http://crbug.com/366580.
+TEST_F(IdleTest, ReAddListener) {
+ idle_provider_->set_locked(false);
+
+ {
+ // Fire idle event.
+ ScopedListen listen(idle_manager_, "test");
+ idle_provider_->set_idle_time(60);
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_IDLE));
+ idle_manager_->UpdateIdleState();
+ testing::Mock::VerifyAndClearExpectations(event_delegate_);
+ }
+
+ // Trigger active.
+ idle_provider_->set_idle_time(0);
+ idle_manager_->UpdateIdleState();
+
+ {
+ // Nothing should have fired, the listener wasn't added until afterward.
+ ScopedListen listen(idle_manager_, "test");
+ idle_manager_->UpdateIdleState();
+ testing::Mock::VerifyAndClearExpectations(event_delegate_);
+ }
+}
+
} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/extensions/api/idle/idle_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698