| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. |
| 423 pid_t shim_pid; | 423 pid_t shim_pid; |
| 424 EXPECT_EQ(noErr, GetProcessPID(&shim_psn, &shim_pid)); | 424 EXPECT_EQ(noErr, GetProcessPID(&shim_psn, &shim_pid)); |
| 425 GetFirstHostedAppWindow()->window()->Close(); | 425 GetFirstHostedAppWindow()->window()->Close(); |
| 426 // Wait for the window to be closed. | 426 // Wait for the window to be closed. |
| 427 listener.WaitUntilRemoved(); | 427 listener.WaitUntilRemoved(); |
| 428 ASSERT_TRUE( | 428 base::Process shim_process(shim_pid); |
| 429 base::WaitForSingleProcess(shim_pid, TestTimeouts::action_timeout())); | 429 int exit_code; |
| 430 ASSERT_TRUE(shim_process.WaitForExitWithTimeout( |
| 431 TestTimeouts::action_timeout(), &exit_code)); |
| 430 | 432 |
| 431 EXPECT_FALSE(GetFirstHostedAppWindow()); | 433 EXPECT_FALSE(GetFirstHostedAppWindow()); |
| 432 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); | 434 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); |
| 433 } | 435 } |
| 434 } | 436 } |
| 435 | 437 |
| 436 // Test that launching the shim for an app starts the app, and vice versa. | 438 // Test that launching the shim for an app starts the app, and vice versa. |
| 437 // These two cases are combined because the time to run the test is dominated | 439 // These two cases are combined because the time to run the test is dominated |
| 438 // by loading the extension and creating the shim. | 440 // by loading the extension and creating the shim. |
| 439 IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_Launch) { | 441 IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_Launch) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 shim_path, shim_cmdline, kLSLaunchDefaults, &shim_psn)); | 492 shim_path, shim_cmdline, kLSLaunchDefaults, &shim_psn)); |
| 491 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 493 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 492 | 494 |
| 493 ASSERT_TRUE(GetFirstAppWindow()); | 495 ASSERT_TRUE(GetFirstAppWindow()); |
| 494 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); | 496 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); |
| 495 | 497 |
| 496 // If the window is closed, the shim should quit. | 498 // If the window is closed, the shim should quit. |
| 497 pid_t shim_pid; | 499 pid_t shim_pid; |
| 498 EXPECT_EQ(noErr, GetProcessPID(&shim_psn, &shim_pid)); | 500 EXPECT_EQ(noErr, GetProcessPID(&shim_psn, &shim_pid)); |
| 499 GetFirstAppWindow()->GetBaseWindow()->Close(); | 501 GetFirstAppWindow()->GetBaseWindow()->Close(); |
| 500 ASSERT_TRUE( | 502 base::Process shim_process(shim_pid); |
| 501 base::WaitForSingleProcess(shim_pid, TestTimeouts::action_timeout())); | 503 int exit_code; |
| 504 ASSERT_TRUE(shim_process.WaitForExitWithTimeout( |
| 505 TestTimeouts::action_timeout(), &exit_code)); |
| 502 | 506 |
| 503 EXPECT_FALSE(GetFirstAppWindow()); | 507 EXPECT_FALSE(GetFirstAppWindow()); |
| 504 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); | 508 EXPECT_FALSE(HasAppShimHost(profile(), app->id())); |
| 505 } | 509 } |
| 506 } | 510 } |
| 507 | 511 |
| 508 // Test that the shim's lifetime depends on the visibility of windows. I.e. the | 512 // Test that the shim's lifetime depends on the visibility of windows. I.e. the |
| 509 // shim is only active when there are visible windows. | 513 // shim is only active when there are visible windows. |
| 510 IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_ShowWindow) { | 514 IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_ShowWindow) { |
| 511 const extensions::Extension* app = InstallPlatformApp("hidden"); | 515 const extensions::Extension* app = InstallPlatformApp("hidden"); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 // the shim is rebuilt. | 710 // the shim is rebuilt. |
| 707 WindowedAppShimLaunchObserver(app->id()).Wait(); | 711 WindowedAppShimLaunchObserver(app->id()).Wait(); |
| 708 | 712 |
| 709 EXPECT_TRUE(GetFirstAppWindow()); | 713 EXPECT_TRUE(GetFirstAppWindow()); |
| 710 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); | 714 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); |
| 711 } | 715 } |
| 712 | 716 |
| 713 #endif // defined(ARCH_CPU_64_BITS) | 717 #endif // defined(ARCH_CPU_64_BITS) |
| 714 | 718 |
| 715 } // namespace apps | 719 } // namespace apps |
| OLD | NEW |