Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // TODO(mek): there is a delay (and on linux an X roundtrip) between setting | |
| 443 // bounds for a window and being able to read back those same bounds. This | |
| 444 // seems to work to wait long enough, but there are probably still situations | |
| 445 // 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
| |
| 446 const base::TimeDelta kWaitTime = base::TimeDelta::FromSeconds(1); | |
| 447 base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime; | |
| 448 while (base::TimeTicks::Now() < end_time) { | |
| 449 content::RunAllPendingInMessageLoop(); | |
| 450 } | |
| 451 | |
| 452 // make sure the window was properly moved&resized | |
| 453 ASSERT_EQ(bounds, window->GetBaseWindow()->GetBounds()); | |
| 454 | |
| 455 // tell javascript to open a second window | |
| 456 page2_listener.Reply("continue"); | |
| 457 | |
| 458 // wait for javascript to verify that the second window got the updated | |
| 459 // 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.
| |
| 460 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); | |
| 461 | |
| 462 | |
|
Evan Stade
2012/08/29 21:51:11
^H
Marijn Kruisselbrink
2012/08/30 16:46:12
Done.
| |
| 463 // 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.
| |
| 464 page3_listener.Reply("continue"); | |
| 465 | |
| 466 // wait for javascript to verify that the third window got the restored size | |
| 467 // and explicitly specified coordinates. | |
| 468 ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); | |
| 469 } | |
| 470 #endif // defined(TOOLKIT_GTK) | |
|
Evan Stade
2012/08/29 21:51:11
2 spaces before //
Marijn Kruisselbrink
2012/08/30 16:46:12
Done.
| |
| 471 | |
| 413 } // namespace extensions | 472 } // namespace extensions |
| OLD | NEW |