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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "chrome/browser/apps/ephemeral_app_browsertest.h" | 7 #include "chrome/browser/apps/ephemeral_app_browsertest.h" |
8 #include "chrome/browser/apps/ephemeral_app_service.h" | 8 #include "chrome/browser/apps/ephemeral_app_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "content/public/test/test_utils.h" | 10 #include "content/public/test/test_utils.h" |
11 #include "extensions/browser/extension_prefs.h" | 11 #include "extensions/browser/extension_prefs.h" |
12 #include "extensions/browser/extension_registry.h" | 12 #include "extensions/browser/extension_registry.h" |
13 #include "extensions/browser/notification_types.h" | 13 #include "extensions/browser/test_extension_registry_observer.h" |
14 #include "extensions/common/manifest.h" | |
15 | 14 |
16 using extensions::Extension; | 15 using extensions::Extension; |
17 using extensions::ExtensionPrefs; | 16 using extensions::ExtensionPrefs; |
18 using extensions::ExtensionRegistry; | 17 using extensions::ExtensionRegistry; |
19 | 18 |
20 namespace { | 19 namespace { |
21 | 20 |
22 const int kNumTestApps = 2; | 21 const int kNumTestApps = 2; |
23 const char* kTestApps[] = { | 22 const char* kTestApps[] = { |
24 "app_window/generic", | 23 "app_window/generic", |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 base::TimeDelta::FromDays(EphemeralAppService::kAppInactiveThreshold + 1); | 82 base::TimeDelta::FromDays(EphemeralAppService::kAppInactiveThreshold + 1); |
84 prefs->SetLastLaunchTime(inactive_app_id, inactive_launch); | 83 prefs->SetLastLaunchTime(inactive_app_id, inactive_launch); |
85 | 84 |
86 // Set launch time for an active app. | 85 // Set launch time for an active app. |
87 std::string active_app_id = app_ids_[1]; | 86 std::string active_app_id = app_ids_[1]; |
88 base::Time active_launch = time_now - | 87 base::Time active_launch = time_now - |
89 base::TimeDelta::FromDays(EphemeralAppService::kAppKeepThreshold); | 88 base::TimeDelta::FromDays(EphemeralAppService::kAppKeepThreshold); |
90 prefs->SetLastLaunchTime(active_app_id, active_launch); | 89 prefs->SetLastLaunchTime(active_app_id, active_launch); |
91 | 90 |
92 // Perform garbage collection. | 91 // Perform garbage collection. |
93 content::WindowedNotificationObserver uninstall_signal( | 92 extensions::TestExtensionRegistryObserver observer( |
94 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, | 93 ExtensionRegistry::Get(browser()->profile())); |
95 content::Source<Profile>(browser()->profile())); | |
96 GarbageCollectEphemeralApps(); | 94 GarbageCollectEphemeralApps(); |
97 uninstall_signal.Wait(); | 95 observer.WaitForExtensionUninstalled(); |
98 | 96 |
99 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 97 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
100 ASSERT_TRUE(registry); | 98 ASSERT_TRUE(registry); |
101 EXPECT_FALSE(registry->GetExtensionById(inactive_app_id, | 99 EXPECT_FALSE(registry->GetExtensionById(inactive_app_id, |
102 ExtensionRegistry::EVERYTHING)); | 100 ExtensionRegistry::EVERYTHING)); |
103 EXPECT_TRUE( | 101 EXPECT_TRUE( |
104 registry->GetExtensionById(active_app_id, ExtensionRegistry::EVERYTHING)); | 102 registry->GetExtensionById(active_app_id, ExtensionRegistry::EVERYTHING)); |
105 | 103 |
106 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count()); | 104 EXPECT_EQ(1, ephemeral_service->ephemeral_app_count()); |
107 } | 105 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 installed_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP)); | 198 installed_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP)); |
201 EXPECT_FALSE(prefs->HasDisableReason( | 199 EXPECT_FALSE(prefs->HasDisableReason( |
202 running_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP)); | 200 running_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP)); |
203 EXPECT_TRUE(prefs->HasDisableReason( | 201 EXPECT_TRUE(prefs->HasDisableReason( |
204 inactive_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP)); | 202 inactive_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP)); |
205 EXPECT_TRUE(prefs->HasDisableReason( | 203 EXPECT_TRUE(prefs->HasDisableReason( |
206 disabled_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP)); | 204 disabled_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP)); |
207 EXPECT_TRUE(prefs->HasDisableReason( | 205 EXPECT_TRUE(prefs->HasDisableReason( |
208 disabled_app->id(), Extension::DISABLE_PERMISSIONS_INCREASE)); | 206 disabled_app->id(), Extension::DISABLE_PERMISSIONS_INCREASE)); |
209 } | 207 } |
OLD | NEW |