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

Side by Side 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: change the polling loop and its comment a bit Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/app/chrome_command_ids.h" 6 #include "chrome/app/chrome_command_ids.h"
7 #include "chrome/browser/automation/automation_util.h" 7 #include "chrome/browser/automation/automation_util.h"
8 #include "chrome/browser/tab_contents/render_view_context_menu.h" 8 #include "chrome/browser/tab_contents/render_view_context_menu.h"
9 #include "chrome/browser/extensions/extension_test_message_listener.h" 9 #include "chrome/browser/extensions/extension_test_message_listener.h"
10 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 10 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
11 #include "chrome/browser/extensions/shell_window_registry.h" 11 #include "chrome/browser/extensions/shell_window_registry.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/browser/ui/extensions/application_launch.h" 14 #include "chrome/browser/ui/extensions/application_launch.h"
15 #include "chrome/browser/ui/extensions/shell_window.h" 15 #include "chrome/browser/ui/extensions/shell_window.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "base/threading/platform_thread.h"
19 20
20 using content::WebContents; 21 using content::WebContents;
21 22
22 namespace extensions { 23 namespace extensions {
23 24
24 namespace { 25 namespace {
25 // Non-abstract RenderViewContextMenu class. 26 // Non-abstract RenderViewContextMenu class.
26 class PlatformAppContextMenu : public RenderViewContextMenu { 27 class PlatformAppContextMenu : public RenderViewContextMenu {
27 public: 28 public:
28 PlatformAppContextMenu(WebContents* web_contents, 29 PlatformAppContextMenu(WebContents* web_contents,
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 content::Source<content::WebContentsDelegate>(browser())); 404 content::Source<content::WebContentsDelegate>(browser()));
404 LoadAndLaunchPlatformApp("open_link"); 405 LoadAndLaunchPlatformApp("open_link");
405 observer.Wait(); 406 observer.Wait();
406 ASSERT_EQ(2, browser()->tab_count()); 407 ASSERT_EQ(2, browser()->tab_count());
407 } 408 }
408 409
409 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { 410 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
410 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_; 411 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_;
411 } 412 }
412 413
414 // Only implemented in GTK so far.
415 #if defined(TOOLKIT_GTK)
416 // Test that windows created with an id will remember and restore their
417 // geometry when opening new windows.
418 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ShellWindowRestorePosition) {
419 ExtensionTestMessageListener page2_listener("WaitForPage2", true);
420 ExtensionTestMessageListener page3_listener("WaitForPage3", true);
421 ExtensionTestMessageListener done_listener("Done1", false);
422 ExtensionTestMessageListener done2_listener("Done2", false);
423 ExtensionTestMessageListener done3_listener("Done3", false);
424
425 ASSERT_TRUE(LoadAndLaunchPlatformApp("geometry"));
426
427 // Wait for the app to be launched (although this is mostly to have a
428 // message to reply to to let the script know it should create its second
429 // window.
430 ASSERT_TRUE(page2_listener.WaitUntilSatisfied());
431
432 // Wait for the first window to verify its geometry was correctly set
433 // from the default* attributes passed to the create function.
434 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
435
436 // Programatically move and resize the window.
437 ShellWindow* window = GetFirstShellWindow();
438 ASSERT_TRUE(window);
439 gfx::Rect bounds(137, 143, 203, 187);
440 window->GetBaseWindow()->SetBounds(bounds);
441
442 #if defined(TOOLKIT_GTK)
443 // TODO(mek): On GTK we have to wait for a roundtrip to the X server before
444 // a resize actually happens:
445 // "if you call gtk_window_resize() then immediately call
446 // gtk_window_get_size(), the size won't have taken effect yet. After the
447 // window manager processes the resize request, GTK+ receives notification
448 // that the size has changed via a configure event, and the size of the
449 // window gets updated."
450 // Because of this we have to wait for an unknown time for the resize to
451 // actually take effect. So wait upto 10 seconds or until the resize got
452 // handled.
453 while (bounds != window->GetBaseWindow()->GetBounds()) {
454 content::RunAllPendingInMessageLoop();
455 }
456
457 // In the GTK ShellWindow implementation there also is a delay between
458 // getting the correct bounds and it calling SaveWindowPosition, so call that
459 // method explicitly to make sure the value was stored.
460 window->SaveWindowPosition();
Marijn Kruisselbrink 2012/08/30 23:26:35 alternatively I could make the test a friend of Sh
Evan Stade 2012/08/30 23:55:38 meh, it's ok, it's a test.
461 #endif // defined(TOOLKIT_GTK)
462
463 // Make sure the window was properly moved&resized.
464 ASSERT_EQ(bounds, window->GetBaseWindow()->GetBounds());
465
466 // Tell javascript to open a second window.
467 page2_listener.Reply("continue");
468
469 // Wait for javascript to verify that the second window got the updated
470 // coordinates, ignoring the default coordinates passed to the create method.
471 ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
472
473 // Tell javascript to open a third window.
474 page3_listener.Reply("continue");
475
476 // Wait for javascript to verify that the third window got the restored size
477 // and explicitly specified coordinates.
478 ASSERT_TRUE(done3_listener.WaitUntilSatisfied());
479 }
480 #endif // defined(TOOLKIT_GTK)
481
413 } // namespace extensions 482 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/platform_app_browsertest_util.h » ('j') | chrome/browser/ui/gtk/gtk_window_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698