OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/common/shelf/shelf_delegate.h" | 5 #include "ash/common/shelf/shelf_delegate.h" |
6 #include "ash/common/wm_shell.h" | 6 #include "ash/common/wm_shell.h" |
7 #include "ash/shelf/shelf_util.h" | 7 #include "ash/shelf/shelf_util.h" |
8 #include "ash/wm/window_util.h" | 8 #include "ash/wm/window_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "chrome/browser/extensions/extension_browsertest.h" | 11 #include "chrome/browser/extensions/extension_browsertest.h" |
| 12 #include "chrome/browser/ui/app_list/app_list_service.h" |
12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
13 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 14 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
14 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
16 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 17 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
17 #include "chromeos/chromeos_switches.h" | 18 #include "chromeos/chromeos_switches.h" |
18 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
19 #include "mojo/common/common_type_converters.h" | 20 #include "mojo/common/common_type_converters.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
(...skipping 15 matching lines...) Expand all Loading... |
37 }; | 38 }; |
38 | 39 |
39 } // namespace mojo | 40 } // namespace mojo |
40 | 41 |
41 namespace { | 42 namespace { |
42 | 43 |
43 const char kTestAppName[] = "Test Arc App"; | 44 const char kTestAppName[] = "Test Arc App"; |
44 const char kTestAppName2[] = "Test Arc App 2"; | 45 const char kTestAppName2[] = "Test Arc App 2"; |
45 const char kTestAppPackage[] = "test.arc.app.package"; | 46 const char kTestAppPackage[] = "test.arc.app.package"; |
46 const char kTestAppActivity[] = "test.arc.app.package.activity"; | 47 const char kTestAppActivity[] = "test.arc.app.package.activity"; |
47 const char kTestAppActivity2[] = "test.arc.app.package.activity2"; | 48 const char kTestAppActivity2[] = "test.arc.gitapp.package.activity2"; |
48 constexpr int kAppAnimatedThresholdMs = 100; | 49 constexpr int kAppAnimatedThresholdMs = 100; |
49 | 50 |
50 std::string GetTestApp1Id() { | 51 std::string GetTestApp1Id() { |
51 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity); | 52 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity); |
52 } | 53 } |
53 | 54 |
54 std::string GetTestApp2Id() { | 55 std::string GetTestApp2Id() { |
55 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity2); | 56 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity2); |
56 } | 57 } |
57 | 58 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | 146 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
146 app_prefs()->GetApp(GetTestApp1Id()); | 147 app_prefs()->GetApp(GetTestApp1Id()); |
147 ASSERT_TRUE(app_info); | 148 ASSERT_TRUE(app_info); |
148 EXPECT_TRUE(app_info->ready); | 149 EXPECT_TRUE(app_info->ready); |
149 if (multi_app) { | 150 if (multi_app) { |
150 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info2 = | 151 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info2 = |
151 app_prefs()->GetApp(GetTestApp2Id()); | 152 app_prefs()->GetApp(GetTestApp2Id()); |
152 ASSERT_TRUE(app_info2); | 153 ASSERT_TRUE(app_info2); |
153 EXPECT_TRUE(app_info2->ready); | 154 EXPECT_TRUE(app_info2->ready); |
154 } | 155 } |
| 156 } |
155 | 157 |
| 158 void SendPackageAdded(bool package_synced) { |
156 arc::mojom::ArcPackageInfo package_info; | 159 arc::mojom::ArcPackageInfo package_info; |
157 package_info.package_name = kTestAppPackage; | 160 package_info.package_name = kTestAppPackage; |
158 package_info.package_version = 1; | 161 package_info.package_version = 1; |
159 package_info.last_backup_android_id = 1; | 162 package_info.last_backup_android_id = 1; |
160 package_info.last_backup_time = 1; | 163 package_info.last_backup_time = 1; |
161 package_info.sync = false; | 164 package_info.sync = package_synced; |
| 165 package_info.system = false; |
162 app_host()->OnPackageAdded(arc::mojom::ArcPackageInfo::From(package_info)); | 166 app_host()->OnPackageAdded(arc::mojom::ArcPackageInfo::From(package_info)); |
163 | 167 |
164 base::RunLoop().RunUntilIdle(); | 168 base::RunLoop().RunUntilIdle(); |
165 } | 169 } |
166 | 170 |
167 void SendPackageUpdated(bool multi_app) { | 171 void SendPackageUpdated(bool multi_app) { |
168 app_host()->OnPackageAppListRefreshed(kTestAppPackage, | 172 app_host()->OnPackageAppListRefreshed(kTestAppPackage, |
169 GetTestAppsList(multi_app)); | 173 GetTestAppsList(multi_app)); |
170 } | 174 } |
171 | 175 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 TestAction test_action() const { return std::tr1::get<0>(GetParam()); } | 217 TestAction test_action() const { return std::tr1::get<0>(GetParam()); } |
214 | 218 |
215 private: | 219 private: |
216 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherBrowserTest); | 220 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherBrowserTest); |
217 }; | 221 }; |
218 | 222 |
219 // This tests simulates normal workflow for starting Arc app in deferred mode. | 223 // This tests simulates normal workflow for starting Arc app in deferred mode. |
220 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { | 224 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { |
221 // Install app to remember existing apps. | 225 // Install app to remember existing apps. |
222 InstallTestApps(false); | 226 InstallTestApps(false); |
| 227 SendPackageAdded(false); |
223 | 228 |
224 const std::string app_id = GetTestApp1Id(); | 229 const std::string app_id = GetTestApp1Id(); |
225 if (is_pinned()) { | 230 if (is_pinned()) { |
226 shelf_delegate()->PinAppWithID(app_id); | 231 shelf_delegate()->PinAppWithID(app_id); |
227 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 232 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
228 } else { | 233 } else { |
229 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 234 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
230 } | 235 } |
231 | 236 |
232 StopInstance(); | 237 StopInstance(); |
(...skipping 15 matching lines...) Expand all Loading... |
248 // Launching non-ready Arc app creates item on shelf and spinning animation. | 253 // Launching non-ready Arc app creates item on shelf and spinning animation. |
249 arc::LaunchApp(profile(), app_id); | 254 arc::LaunchApp(profile(), app_id); |
250 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 255 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
251 AppAnimatedWaiter(app_id).Wait(); | 256 AppAnimatedWaiter(app_id).Wait(); |
252 | 257 |
253 switch (test_action()) { | 258 switch (test_action()) { |
254 case TEST_ACTION_START: | 259 case TEST_ACTION_START: |
255 // Now simulates that Arc is started and app list is refreshed. This | 260 // Now simulates that Arc is started and app list is refreshed. This |
256 // should stop animation and delete icon from the shelf. | 261 // should stop animation and delete icon from the shelf. |
257 InstallTestApps(false); | 262 InstallTestApps(false); |
| 263 SendPackageAdded(false); |
258 EXPECT_TRUE(chrome_controller() | 264 EXPECT_TRUE(chrome_controller() |
259 ->GetArcDeferredLauncher() | 265 ->GetArcDeferredLauncher() |
260 ->GetActiveTime(app_id) | 266 ->GetActiveTime(app_id) |
261 .is_zero()); | 267 .is_zero()); |
262 if (is_pinned()) | 268 if (is_pinned()) |
263 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 269 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
264 else | 270 else |
265 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); | 271 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); |
266 break; | 272 break; |
267 case TEST_ACTION_EXIT: | 273 case TEST_ACTION_EXIT: |
(...skipping 20 matching lines...) Expand all Loading... |
288 } | 294 } |
289 } | 295 } |
290 | 296 |
291 INSTANTIATE_TEST_CASE_P(ArcAppDeferredLauncherBrowserTestInstance, | 297 INSTANTIATE_TEST_CASE_P(ArcAppDeferredLauncherBrowserTestInstance, |
292 ArcAppDeferredLauncherBrowserTest, | 298 ArcAppDeferredLauncherBrowserTest, |
293 ::testing::ValuesIn(build_test_parameter)); | 299 ::testing::ValuesIn(build_test_parameter)); |
294 | 300 |
295 // This tests validates pin state on package update and remove. | 301 // This tests validates pin state on package update and remove. |
296 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) { | 302 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) { |
297 InstallTestApps(true); | 303 InstallTestApps(true); |
| 304 SendPackageAdded(false); |
298 | 305 |
299 const std::string app_id1 = GetTestApp1Id(); | 306 const std::string app_id1 = GetTestApp1Id(); |
300 const std::string app_id2 = GetTestApp2Id(); | 307 const std::string app_id2 = GetTestApp2Id(); |
301 shelf_delegate()->PinAppWithID(app_id1); | 308 shelf_delegate()->PinAppWithID(app_id1); |
302 shelf_delegate()->PinAppWithID(app_id2); | 309 shelf_delegate()->PinAppWithID(app_id2); |
303 const ash::ShelfID shelf_id1_before = | 310 const ash::ShelfID shelf_id1_before = |
304 shelf_delegate()->GetShelfIDForAppID(app_id1); | 311 shelf_delegate()->GetShelfIDForAppID(app_id1); |
305 EXPECT_TRUE(shelf_id1_before); | 312 EXPECT_TRUE(shelf_id1_before); |
306 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 313 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id2)); |
307 | 314 |
308 // Package contains only one app. | 315 // Package contains only one app. App list is not shown for updated package. |
309 SendPackageUpdated(false); | 316 SendPackageUpdated(false); |
310 // Second pin should gone. | 317 // Second pin should gone. |
311 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); | 318 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); |
312 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 319 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); |
313 | 320 |
314 // Package contains two apps. | 321 // Package contains two apps. App list is not shown for updated package. |
315 SendPackageUpdated(true); | 322 SendPackageUpdated(true); |
316 // Second pin should not appear. | 323 // Second pin should not appear. |
317 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); | 324 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); |
318 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 325 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); |
319 | 326 |
320 // Package removed. | 327 // Package removed. |
321 SendPackageRemoved(); | 328 SendPackageRemoved(); |
322 // No pin is expected. | 329 // No pin is expected. |
323 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id1)); | 330 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id1)); |
324 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); | 331 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); |
325 } | 332 } |
| 333 |
| 334 // This test validates that app list is shown on new package and not shown |
| 335 // on package update. |
| 336 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, AppListShown) { |
| 337 AppListService* app_list_service = AppListService::Get(); |
| 338 ASSERT_TRUE(app_list_service); |
| 339 |
| 340 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 341 |
| 342 // New package is available. Show app list. |
| 343 InstallTestApps(false); |
| 344 SendPackageAdded(true); |
| 345 EXPECT_TRUE(app_list_service->IsAppListVisible()); |
| 346 |
| 347 app_list_service->DismissAppList(); |
| 348 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 349 |
| 350 // Send package update event. App list is not shown. |
| 351 SendPackageAdded(true); |
| 352 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 353 } |
OLD | NEW |