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 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 service_->OnAppStart(&profile_, "foo"); | 71 service_->OnAppStart(&profile_, "foo"); |
72 EXPECT_TRUE(chrome::WillKeepAlive()); | 72 EXPECT_TRUE(chrome::WillKeepAlive()); |
73 service_->OnAppStart(&profile_, "foo"); | 73 service_->OnAppStart(&profile_, "foo"); |
74 EXPECT_TRUE(chrome::WillKeepAlive()); | 74 EXPECT_TRUE(chrome::WillKeepAlive()); |
75 service_->OnAppStop(&profile_, "foo"); | 75 service_->OnAppStop(&profile_, "foo"); |
76 EXPECT_FALSE(chrome::WillKeepAlive()); | 76 EXPECT_FALSE(chrome::WillKeepAlive()); |
77 service_->Shutdown(); | 77 service_->Shutdown(); |
78 EXPECT_FALSE(chrome::WillKeepAlive()); | 78 EXPECT_FALSE(chrome::WillKeepAlive()); |
79 } | 79 } |
80 | 80 |
| 81 // Test that OnAppStart is ignored after the service has been shut down. |
| 82 TEST_F(AppKeepAliveServiceUnitTest, StartAfterShutdown) { |
| 83 ASSERT_FALSE(chrome::WillKeepAlive()); |
| 84 service_->Shutdown(); |
| 85 service_->OnAppStart(&profile_, "foo"); |
| 86 EXPECT_FALSE(chrome::WillKeepAlive()); |
| 87 } |
| 88 |
81 TEST_F(AppKeepAliveServiceUnitTest, MultipleApps) { | 89 TEST_F(AppKeepAliveServiceUnitTest, MultipleApps) { |
82 ASSERT_FALSE(chrome::WillKeepAlive()); | 90 ASSERT_FALSE(chrome::WillKeepAlive()); |
83 service_->OnAppStart(&profile_, "foo"); | 91 service_->OnAppStart(&profile_, "foo"); |
84 EXPECT_TRUE(chrome::WillKeepAlive()); | 92 EXPECT_TRUE(chrome::WillKeepAlive()); |
85 service_->OnAppStart(&profile_, "bar"); | 93 service_->OnAppStart(&profile_, "bar"); |
86 EXPECT_TRUE(chrome::WillKeepAlive()); | 94 EXPECT_TRUE(chrome::WillKeepAlive()); |
87 service_->OnAppStop(&profile_, "foo"); | 95 service_->OnAppStop(&profile_, "foo"); |
88 EXPECT_TRUE(chrome::WillKeepAlive()); | 96 EXPECT_TRUE(chrome::WillKeepAlive()); |
89 service_->OnAppStop(&profile_, "bar"); | 97 service_->OnAppStop(&profile_, "bar"); |
90 EXPECT_FALSE(chrome::WillKeepAlive()); | 98 EXPECT_FALSE(chrome::WillKeepAlive()); |
(...skipping 21 matching lines...) Expand all Loading... |
112 TEST_F(AppKeepAliveServiceUnitTest, ProfileShutdownWithAppsStarted) { | 120 TEST_F(AppKeepAliveServiceUnitTest, ProfileShutdownWithAppsStarted) { |
113 ASSERT_FALSE(chrome::WillKeepAlive()); | 121 ASSERT_FALSE(chrome::WillKeepAlive()); |
114 service_->OnAppStart(&profile_, "foo"); | 122 service_->OnAppStart(&profile_, "foo"); |
115 EXPECT_TRUE(chrome::WillKeepAlive()); | 123 EXPECT_TRUE(chrome::WillKeepAlive()); |
116 service_->OnAppStart(&profile_, "bar"); | 124 service_->OnAppStart(&profile_, "bar"); |
117 EXPECT_TRUE(chrome::WillKeepAlive()); | 125 EXPECT_TRUE(chrome::WillKeepAlive()); |
118 service_->Shutdown(); | 126 service_->Shutdown(); |
119 EXPECT_FALSE(chrome::WillKeepAlive()); | 127 EXPECT_FALSE(chrome::WillKeepAlive()); |
120 } | 128 } |
121 #endif | 129 #endif |
OLD | NEW |