OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "apps/app_lifetime_monitor_factory.h" | 8 #include "apps/app_lifetime_monitor_factory.h" |
9 #include "apps/switches.h" | 9 #include "apps/switches.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 [running_shim objectAtIndex:0]) terminate]; | 402 [running_shim objectAtIndex:0]) terminate]; |
403 [ns_observer wait]; | 403 [ns_observer wait]; |
404 | 404 |
405 EXPECT_FALSE(GetFirstHostedAppWindow()); | 405 EXPECT_FALSE(GetFirstHostedAppWindow()); |
406 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); | 406 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); |
407 } | 407 } |
408 | 408 |
409 // Case 2: Launch the shim, it should start the hosted app. | 409 // Case 2: Launch the shim, it should start the hosted app. |
410 { | 410 { |
411 HostedAppBrowserListObserver listener(app->id()); | 411 HostedAppBrowserListObserver listener(app->id()); |
412 CommandLine shim_cmdline(CommandLine::NO_PROGRAM); | 412 base::CommandLine shim_cmdline(base::CommandLine::NO_PROGRAM); |
413 shim_cmdline.AppendSwitch(app_mode::kLaunchedForTest); | 413 shim_cmdline.AppendSwitch(app_mode::kLaunchedForTest); |
414 ProcessSerialNumber shim_psn; | 414 ProcessSerialNumber shim_psn; |
415 ASSERT_TRUE(base::mac::OpenApplicationWithPath( | 415 ASSERT_TRUE(base::mac::OpenApplicationWithPath( |
416 shim_path, shim_cmdline, kLSLaunchDefaults, &shim_psn)); | 416 shim_path, shim_cmdline, kLSLaunchDefaults, &shim_psn)); |
417 listener.WaitUntilAdded(); | 417 listener.WaitUntilAdded(); |
418 | 418 |
419 ASSERT_TRUE(GetFirstHostedAppWindow()); | 419 ASSERT_TRUE(GetFirstHostedAppWindow()); |
420 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); | 420 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); |
421 | 421 |
422 // If the window is closed, the shim should quit. | 422 // If the window is closed, the shim should quit. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 [running_shim objectAtIndex:0]) terminate]; | 476 [running_shim objectAtIndex:0]) terminate]; |
477 [ns_observer wait]; | 477 [ns_observer wait]; |
478 | 478 |
479 EXPECT_FALSE(GetFirstAppWindow()); | 479 EXPECT_FALSE(GetFirstAppWindow()); |
480 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); | 480 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); |
481 } | 481 } |
482 | 482 |
483 // Case 2: Launch the shim, it should start the app. | 483 // Case 2: Launch the shim, it should start the app. |
484 { | 484 { |
485 ExtensionTestMessageListener launched_listener("Launched", false); | 485 ExtensionTestMessageListener launched_listener("Launched", false); |
486 CommandLine shim_cmdline(CommandLine::NO_PROGRAM); | 486 base::CommandLine shim_cmdline(base::CommandLine::NO_PROGRAM); |
487 shim_cmdline.AppendSwitch(app_mode::kLaunchedForTest); | 487 shim_cmdline.AppendSwitch(app_mode::kLaunchedForTest); |
488 ProcessSerialNumber shim_psn; | 488 ProcessSerialNumber shim_psn; |
489 ASSERT_TRUE(base::mac::OpenApplicationWithPath( | 489 ASSERT_TRUE(base::mac::OpenApplicationWithPath( |
490 shim_path, shim_cmdline, kLSLaunchDefaults, &shim_psn)); | 490 shim_path, shim_cmdline, kLSLaunchDefaults, &shim_psn)); |
491 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 491 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
492 | 492 |
493 ASSERT_TRUE(GetFirstAppWindow()); | 493 ASSERT_TRUE(GetFirstAppWindow()); |
494 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); | 494 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); |
495 | 495 |
496 // If the window is closed, the shim should quit. | 496 // If the window is closed, the shim should quit. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 // Launch the shim, it should start the app and ultimately connect over IPC. | 685 // Launch the shim, it should start the app and ultimately connect over IPC. |
686 // This actually happens in multiple launches of the shim: | 686 // This actually happens in multiple launches of the shim: |
687 // (1) The shim will fail and instead launch Chrome with --app-id so that the | 687 // (1) The shim will fail and instead launch Chrome with --app-id so that the |
688 // app starts. | 688 // app starts. |
689 // (2) Chrome launches the shim in response to an app starting, this time the | 689 // (2) Chrome launches the shim in response to an app starting, this time the |
690 // shim launches Chrome with --app-shim-error, which causes Chrome to | 690 // shim launches Chrome with --app-shim-error, which causes Chrome to |
691 // rebuild the shim. | 691 // rebuild the shim. |
692 // (3) After rebuilding, Chrome again launches the shim and expects it to | 692 // (3) After rebuilding, Chrome again launches the shim and expects it to |
693 // behave normally. | 693 // behave normally. |
694 ExtensionTestMessageListener launched_listener("Launched", false); | 694 ExtensionTestMessageListener launched_listener("Launched", false); |
695 CommandLine shim_cmdline(CommandLine::NO_PROGRAM); | 695 base::CommandLine shim_cmdline(base::CommandLine::NO_PROGRAM); |
696 ASSERT_TRUE(base::mac::OpenApplicationWithPath( | 696 ASSERT_TRUE(base::mac::OpenApplicationWithPath( |
697 shim_path, shim_cmdline, kLSLaunchDefaults, NULL)); | 697 shim_path, shim_cmdline, kLSLaunchDefaults, NULL)); |
698 | 698 |
699 // Wait for the app to start (1). At this point there is no shim host. | 699 // Wait for the app to start (1). At this point there is no shim host. |
700 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 700 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
701 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); | 701 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); |
702 | 702 |
703 // Wait for the rebuilt shim to connect (3). This does not race with the app | 703 // Wait for the rebuilt shim to connect (3). This does not race with the app |
704 // starting (1) because Chrome only launches the shim (2) after the app | 704 // starting (1) because Chrome only launches the shim (2) after the app |
705 // starts. Then Chrome must handle --app-shim-error on the UI thread before | 705 // starts. Then Chrome must handle --app-shim-error on the UI thread before |
706 // the shim is rebuilt. | 706 // the shim is rebuilt. |
707 WindowedAppShimLaunchObserver(app->id()).Wait(); | 707 WindowedAppShimLaunchObserver(app->id()).Wait(); |
708 | 708 |
709 EXPECT_TRUE(GetFirstAppWindow()); | 709 EXPECT_TRUE(GetFirstAppWindow()); |
710 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); | 710 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); |
711 } | 711 } |
712 | 712 |
713 #endif // defined(ARCH_CPU_64_BITS) | 713 #endif // defined(ARCH_CPU_64_BITS) |
714 | 714 |
715 } // namespace apps | 715 } // namespace apps |
OLD | NEW |