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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/idle/idle_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/idle/idle_api.h" 5 #include "chrome/browser/extensions/api/idle/idle_api.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 TEST_F(IdleTest, UnloadWhileListening) { 543 TEST_F(IdleTest, UnloadWhileListening) {
544 ScopedListen listen(idle_manager_, extension()->id()); 544 ScopedListen listen(idle_manager_, extension()->id());
545 UnloadedExtensionInfo details(extension(), 545 UnloadedExtensionInfo details(extension(),
546 UnloadedExtensionInfo::REASON_UNINSTALL); 546 UnloadedExtensionInfo::REASON_UNINSTALL);
547 idle_manager_->Observe( 547 idle_manager_->Observe(
548 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 548 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
549 content::Source<Profile>(browser()->profile()), 549 content::Source<Profile>(browser()->profile()),
550 content::Details<UnloadedExtensionInfo>(&details)); 550 content::Details<UnloadedExtensionInfo>(&details));
551 } 551 }
552 552
553 // Verifies that re-adding a listener after a state change doesn't immediately
554 // fire a change event. Regression test for http://crbug.com/366580.
555 TEST_F(IdleTest, ReAddListener) {
556 idle_provider_->set_locked(false);
557
558 {
559 // Fire idle event.
560 ScopedListen listen(idle_manager_, "test");
561 idle_provider_->set_idle_time(60);
562 EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_IDLE));
563 idle_manager_->UpdateIdleState();
564 testing::Mock::VerifyAndClearExpectations(event_delegate_);
565 }
566
567 // Trigger active.
568 idle_provider_->set_idle_time(0);
569 idle_manager_->UpdateIdleState();
570
571 {
572 // Nothing should have fired, the listener wasn't added until afterward.
573 ScopedListen listen(idle_manager_, "test");
574 idle_manager_->UpdateIdleState();
575 testing::Mock::VerifyAndClearExpectations(event_delegate_);
576 }
577 }
578
553 } // namespace extensions 579 } // namespace extensions
OLDNEW
« 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