OLD | NEW |
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 Loading... |
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 |
OLD | NEW |