Chromium Code Reviews| 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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
| 6 #include "chrome/browser/ui/browser_iterator.h" | |
| 7 #include "chrome/browser/ui/browser_window.h" | |
| 6 #include "chrome/test/base/interactive_test_utils.h" | 8 #include "chrome/test/base/interactive_test_utils.h" |
| 7 #include "extensions/browser/app_window/native_app_window.h" | 9 #include "extensions/browser/app_window/native_app_window.h" |
| 8 #include "extensions/test/extension_test_message_listener.h" | 10 #include "extensions/test/extension_test_message_listener.h" |
| 9 #include "extensions/test/result_catcher.h" | 11 #include "extensions/test/result_catcher.h" |
| 10 | 12 |
| 11 #if defined(OS_MACOSX) && !defined(OS_IOS) | 13 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 12 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 13 #endif | 15 #endif |
| 14 | 16 |
| 15 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 ASSERT_TRUE(RunAppWindowInteractiveTest("testCreate")) << message_; | 452 ASSERT_TRUE(RunAppWindowInteractiveTest("testCreate")) << message_; |
| 451 } | 453 } |
| 452 | 454 |
| 453 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestShow) { | 455 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestShow) { |
| 454 ASSERT_TRUE(RunAppWindowInteractiveTest("testShow")) << message_; | 456 ASSERT_TRUE(RunAppWindowInteractiveTest("testShow")) << message_; |
| 455 } | 457 } |
| 456 | 458 |
| 457 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestDrawAttention) { | 459 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestDrawAttention) { |
| 458 ASSERT_TRUE(RunAppWindowInteractiveTest("testDrawAttention")) << message_; | 460 ASSERT_TRUE(RunAppWindowInteractiveTest("testDrawAttention")) << message_; |
| 459 } | 461 } |
| 462 | |
| 463 // In general, hidden windows should not keep Chrome alive. The exception is | |
| 464 // when windows are created hidden, we allow the app some time to show the | |
| 465 // the window. | |
| 466 class AppWindowHiddenKeepAliveTest : public extensions::PlatformAppBrowserTest { | |
| 467 protected: | |
| 468 AppWindowHiddenKeepAliveTest() {} | |
| 469 | |
| 470 private: | |
| 471 DISALLOW_COPY_AND_ASSIGN(AppWindowHiddenKeepAliveTest); | |
| 472 }; | |
| 473 | |
| 474 // A window that becomes hidden should not keep Chrome alive. | |
| 475 IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, ShownThenHidden) { | |
| 476 LoadAndLaunchPlatformApp("minimal", "Launched"); | |
| 477 GetFirstAppWindow()->Hide(); | |
| 478 | |
| 479 for (chrome::BrowserIterator it; !it.done(); it.Next()) | |
| 480 it->window()->Close(); | |
| 481 // This will time out if the command above does not terminate Chrome. | |
| 482 content::RunMessageLoop(); | |
| 483 } | |
| 484 | |
| 485 // An window that is created hidden and stays hidden should not keep Chrome | |
|
benwells
2015/02/10 07:25:10
Nit: A window...
jackhou1
2015/02/10 23:33:20
Done.
benwells
2015/02/12 22:55:08
Nit: no it's not...
jackhou1
2015/02/15 23:00:27
Oops, I fixed the one below and not this one. Done
| |
| 486 // alive. | |
| 487 IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, StaysHidden) { | |
| 488 LoadAndLaunchPlatformApp("hidden", "Launched"); | |
| 489 AppWindow* app_window = GetFirstAppWindow(); | |
| 490 EXPECT_TRUE(app_window->is_hidden()); | |
| 491 | |
| 492 for (chrome::BrowserIterator it; !it.done(); it.Next()) | |
| 493 it->window()->Close(); | |
| 494 // This will time out if the command above does not terminate Chrome. | |
| 495 content::RunMessageLoop(); | |
| 496 } | |
| 497 | |
| 498 // An window that is created hidden but shown soon after should keep Chrome | |
| 499 // alive. | |
| 500 IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, HiddenThenShown) { | |
|
benwells
2015/02/10 07:25:10
Have you verified this test fails if the keepalive
jackhou1
2015/02/10 23:33:20
In this case, the ChromeAppDelegate just avoids re
| |
| 501 ExtensionTestMessageListener launched_listener("Launched", true); | |
| 502 LoadAndLaunchPlatformApp("hidden_then_shown", &launched_listener); | |
| 503 AppWindow* app_window = GetFirstAppWindow(); | |
| 504 EXPECT_TRUE(app_window->is_hidden()); | |
| 505 | |
| 506 // Close all browser windows. | |
| 507 for (chrome::BrowserIterator it; !it.done(); it.Next()) | |
| 508 it->window()->Close(); | |
| 509 | |
| 510 // The app window will show after 3 seconds. | |
| 511 ExtensionTestMessageListener shown_listener("Shown", false); | |
| 512 launched_listener.Reply(""); | |
| 513 EXPECT_TRUE(shown_listener.WaitUntilSatisfied()); | |
| 514 EXPECT_FALSE(app_window->is_hidden()); | |
| 515 } | |
| OLD | NEW |