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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 EXPECT_CALL(*event_delegate_, | 505 EXPECT_CALL(*event_delegate_, |
506 OnStateChanged(extension()->id(), IDLE_STATE_IDLE)); | 506 OnStateChanged(extension()->id(), IDLE_STATE_IDLE)); |
507 idle_manager_->UpdateIdleState(); | 507 idle_manager_->UpdateIdleState(); |
508 testing::Mock::VerifyAndClearExpectations(event_delegate_); | 508 testing::Mock::VerifyAndClearExpectations(event_delegate_); |
509 } | 509 } |
510 | 510 |
511 // Threshold will reset after unload (and listen count == 0) | 511 // Threshold will reset after unload (and listen count == 0) |
512 UnloadedExtensionInfo details(extension(), | 512 UnloadedExtensionInfo details(extension(), |
513 UnloadedExtensionInfo::REASON_UNINSTALL); | 513 UnloadedExtensionInfo::REASON_UNINSTALL); |
514 idle_manager_->Observe( | 514 idle_manager_->Observe( |
515 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 515 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
516 content::Source<Profile>(browser()->profile()), | 516 content::Source<Profile>(browser()->profile()), |
517 content::Details<UnloadedExtensionInfo>(&details)); | 517 content::Details<UnloadedExtensionInfo>(&details)); |
518 | 518 |
519 { | 519 { |
520 ScopedListen listen(idle_manager_, extension()->id()); | 520 ScopedListen listen(idle_manager_, extension()->id()); |
521 idle_manager_->UpdateIdleState(); | 521 idle_manager_->UpdateIdleState(); |
522 testing::Mock::VerifyAndClearExpectations(event_delegate_); | 522 testing::Mock::VerifyAndClearExpectations(event_delegate_); |
523 | 523 |
524 idle_provider_->set_idle_time(61); | 524 idle_provider_->set_idle_time(61); |
525 EXPECT_CALL(*event_delegate_, | 525 EXPECT_CALL(*event_delegate_, |
526 OnStateChanged(extension()->id(), IDLE_STATE_IDLE)); | 526 OnStateChanged(extension()->id(), IDLE_STATE_IDLE)); |
527 idle_manager_->UpdateIdleState(); | 527 idle_manager_->UpdateIdleState(); |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 // Verifies that unloading an extension with no listeners or threshold works. | 531 // Verifies that unloading an extension with no listeners or threshold works. |
532 TEST_F(IdleTest, UnloadOnly) { | 532 TEST_F(IdleTest, UnloadOnly) { |
533 UnloadedExtensionInfo details(extension(), | 533 UnloadedExtensionInfo details(extension(), |
534 UnloadedExtensionInfo::REASON_UNINSTALL); | 534 UnloadedExtensionInfo::REASON_UNINSTALL); |
535 idle_manager_->Observe( | 535 idle_manager_->Observe( |
536 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 536 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
537 content::Source<Profile>(browser()->profile()), | 537 content::Source<Profile>(browser()->profile()), |
538 content::Details<UnloadedExtensionInfo>(&details)); | 538 content::Details<UnloadedExtensionInfo>(&details)); |
539 } | 539 } |
540 | 540 |
541 // Verifies that its ok for the unload notification to happen before all the | 541 // Verifies that its ok for the unload notification to happen before all the |
542 // listener removals. | 542 // listener removals. |
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, | 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 } // namespace extensions | 553 } // namespace extensions |
OLD | NEW |