| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/app_keep_alive_service.h" | 5 #include "apps/app_keep_alive_service.h" |
| 6 #include "apps/app_keep_alive_service_factory.h" | 6 #include "apps/app_keep_alive_service_factory.h" |
| 7 #include "chrome/browser/lifetime/application_lifetime.h" | 7 #include "chrome/browser/lifetime/application_lifetime.h" |
| 8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 #if !defined(OS_ANDROID) | 11 #if !defined(OS_ANDROID) |
| 12 | 12 |
| 13 class AppKeepAliveServiceUnitTest : public testing::Test { | 13 class AppKeepAliveServiceUnitTest : public testing::Test { |
| 14 protected: | 14 protected: |
| 15 virtual void SetUp() OVERRIDE { | 15 virtual void SetUp() OVERRIDE { |
| 16 testing::Test::SetUp(); | 16 testing::Test::SetUp(); |
| 17 service_.reset(new apps::AppKeepAliveService(&profile_)); | 17 service_.reset(new apps::AppKeepAliveService(&profile_)); |
| 18 } | 18 } |
| 19 | 19 |
| 20 virtual void TearDown() OVERRIDE { | 20 virtual void TearDown() OVERRIDE { |
| 21 while (chrome::WillKeepAlive()) | 21 while (chrome::WillKeepAlive()) |
| 22 chrome::EndKeepAlive(); | 22 chrome::DecrementKeepAliveCount(); |
| 23 testing::Test::TearDown(); | 23 testing::Test::TearDown(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 TestingProfile profile_; | 26 TestingProfile profile_; |
| 27 scoped_ptr<apps::AppKeepAliveService> service_; | 27 scoped_ptr<apps::AppKeepAliveService> service_; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 TEST_F(AppKeepAliveServiceUnitTest, Basic) { | 30 TEST_F(AppKeepAliveServiceUnitTest, Basic) { |
| 31 ASSERT_FALSE(chrome::WillKeepAlive()); | 31 ASSERT_FALSE(chrome::WillKeepAlive()); |
| 32 service_->OnAppStart(&profile_, "foo"); | 32 service_->OnAppStart(&profile_, "foo"); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 TEST_F(AppKeepAliveServiceUnitTest, ProfileShutdownWithAppsStarted) { | 120 TEST_F(AppKeepAliveServiceUnitTest, ProfileShutdownWithAppsStarted) { |
| 121 ASSERT_FALSE(chrome::WillKeepAlive()); | 121 ASSERT_FALSE(chrome::WillKeepAlive()); |
| 122 service_->OnAppStart(&profile_, "foo"); | 122 service_->OnAppStart(&profile_, "foo"); |
| 123 EXPECT_TRUE(chrome::WillKeepAlive()); | 123 EXPECT_TRUE(chrome::WillKeepAlive()); |
| 124 service_->OnAppStart(&profile_, "bar"); | 124 service_->OnAppStart(&profile_, "bar"); |
| 125 EXPECT_TRUE(chrome::WillKeepAlive()); | 125 EXPECT_TRUE(chrome::WillKeepAlive()); |
| 126 service_->Shutdown(); | 126 service_->Shutdown(); |
| 127 EXPECT_FALSE(chrome::WillKeepAlive()); | 127 EXPECT_FALSE(chrome::WillKeepAlive()); |
| 128 } | 128 } |
| 129 #endif | 129 #endif |
| OLD | NEW |