Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4406)

Unified Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10871087: GTK implementation of remembering platform app window geometry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: properly limit the test to just gtk, not all linux Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 df84214388380c9c6f06d593a855986256fa0d30..a9c7d5f57a7ed61332d3b182952d009f3e8b8cb8 100644
--- a/chrome/browser/extensions/platform_app_browsertest.cc
+++ b/chrome/browser/extensions/platform_app_browsertest.cc
@@ -16,6 +16,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;
@@ -410,4 +411,62 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_;
}
+// Only implemented in GTK so far.
+#if defined(TOOLKIT_GTK)
+// 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.
Evan Stade 2012/08/29 21:51:11 polling is better than spinning, but still sucks.
Marijn Kruisselbrink 2012/08/30 16:46:12 Just calling OnDebounceBoundsChanged is not enough
Evan Stade 2012/08/30 21:59:22 the bottom line is that introducing a timeout like
Marijn Kruisselbrink 2012/08/30 23:26:35 Okay, I read through GTK+ code, and the conclusion
Evan Stade 2012/08/30 23:55:38 there's nothing wrong with waiting for that size c
+ const base::TimeDelta kWaitTime = base::TimeDelta::FromSeconds(1);
+ base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime;
+ while (base::TimeTicks::Now() < end_time) {
+ content::RunAllPendingInMessageLoop();
+ }
+
+ // 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.
Evan Stade 2012/08/29 21:51:11 what does the asterisk mean here
Marijn Kruisselbrink 2012/08/30 16:46:12 Done.
+ ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
+
+
Evan Stade 2012/08/29 21:51:11 ^H
Marijn Kruisselbrink 2012/08/30 16:46:12 Done.
+ // tell javascript to open a third window
Evan Stade 2012/08/29 21:51:11 sentence-like punctuation and capitalization in co
Marijn Kruisselbrink 2012/08/30 16:46:12 Done.
+ 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(TOOLKIT_GTK)
Evan Stade 2012/08/29 21:51:11 2 spaces before //
Marijn Kruisselbrink 2012/08/30 16:46:12 Done.
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698