Chromium Code Reviews| Index: chrome/browser/extensions/platform_app_browsertest.cc |
| diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc |
| index da77893260beac04e3476220f861bbe684e0b8ae..ba86314f414f9d033c6c56c7395d9326320ff164 100644 |
| --- a/chrome/browser/extensions/platform_app_browsertest.cc |
| +++ b/chrome/browser/extensions/platform_app_browsertest.cc |
| @@ -15,6 +15,7 @@ |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| #include "content/public/browser/render_process_host.h" |
| +#include "base/threading/platform_thread.h" |
| using content::WebContents; |
| @@ -342,4 +343,62 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { |
| ASSERT_EQ(2, browser()->tab_count()); |
| } |
| +// only implemented on linux so far |
| +#if defined(OS_LINUX) |
| +// Test that windows created with an id will remember and restore their |
| +// geometry when opening new windows. |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ShellWindowRestorePosition) { |
| + ExtensionTestMessageListener page2_listener("WaitForPage2", true); |
| + ExtensionTestMessageListener page3_listener("WaitForPage3", true); |
| + ExtensionTestMessageListener done_listener("Done1", false); |
| + ExtensionTestMessageListener done2_listener("Done2", false); |
| + ExtensionTestMessageListener done3_listener("Done3", false); |
| + |
| + ASSERT_TRUE(LoadAndLaunchPlatformApp("geometry")); |
| + |
| + // Wait for the app to be launched (although this is mostly to have a |
| + // message to reply to to let the script know it should create its second |
| + // window. |
| + ASSERT_TRUE(page2_listener.WaitUntilSatisfied()); |
| + |
| + // Wait for the first window to verify its geometry was correctly set |
| + // from the default* attributes passed to the create function. |
| + ASSERT_TRUE(done_listener.WaitUntilSatisfied()); |
| + |
| + // programatically move and resize the window |
| + ShellWindow* window = GetFirstShellWindow(); |
| + ASSERT_TRUE(window); |
| + gfx::Rect bounds(137, 143, 203, 187); |
| + window->GetBaseWindow()->SetBounds(bounds); |
| + |
| + // TODO(mek): there is a delay (and on linux an X roundtrip) between setting |
| + // bounds for a window and being able to read back those same bounds. This |
| + // seems to work to wait long enough, but there are probably still situations |
| + // where timing still works out badly. |
| + const base::TimeDelta kWaitTime = base::TimeDelta::FromSeconds(1); |
| + base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime; |
| + while (base::TimeTicks::Now() < end_time) { |
| + content::RunAllPendingInMessageLoop(); |
| + } |
|
asargent_no_longer_on_chrome
2012/08/29 00:01:56
Instead of always waiting 1 second to read back th
|
| + |
| + // make sure the window was properly moved&resized |
| + ASSERT_EQ(bounds, window->GetBaseWindow()->GetBounds()); |
| + |
| + // tell javascript to open a second window |
| + page2_listener.Reply("continue"); |
| + |
| + // wait for javascript to verify that the second window got the updated |
| + // coordinates, ignoring its default* create params. |
| + ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); |
| + |
| + |
| + // tell javascript to open a third window |
| + page3_listener.Reply("continue"); |
| + |
| + // wait for javascript to verify that the third window got the restored size |
| + // and explicitly specified coordinates. |
| + ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); |
| +} |
| +#endif // defined(OS_LINUX) |
| + |
| } // namespace extensions |