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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/devtools/devtools_window.h" | 8 #include "chrome/browser/devtools/devtools_window.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/net/url_request_mock_util.h" | 10 #include "chrome/browser/net/url_request_mock_util.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 Panel* panel = CreatePanelWithParams(params); | 416 Panel* panel = CreatePanelWithParams(params); |
417 | 417 |
418 // Ensure panel has auto resized to original web content size. | 418 // Ensure panel has auto resized to original web content size. |
419 // The resize will update the docked panel collection. | 419 // The resize will update the docked panel collection. |
420 WaitForStableInitialSize initial_resize(panel); | 420 WaitForStableInitialSize initial_resize(panel); |
421 initial_resize.Wait(); | 421 initial_resize.Wait(); |
422 gfx::Rect initial_bounds = panel->GetBounds(); | 422 gfx::Rect initial_bounds = panel->GetBounds(); |
423 | 423 |
424 // Expand the test page. The resize will update the docked panel collection. | 424 // Expand the test page. The resize will update the docked panel collection. |
425 WaitForAutoResizeWider enlarge(panel); | 425 WaitForAutoResizeWider enlarge(panel); |
426 EXPECT_TRUE(content::ExecuteJavaScript( | 426 EXPECT_TRUE(content::ExecuteScript( |
427 panel->GetWebContents()->GetRenderViewHost(), | 427 panel->GetWebContents(), "changeSize(50);")); |
428 "", | |
429 "changeSize(50);")); | |
430 enlarge.Wait(); | 428 enlarge.Wait(); |
431 gfx::Rect bounds_on_grow = panel->GetBounds(); | 429 gfx::Rect bounds_on_grow = panel->GetBounds(); |
432 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); | 430 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); |
433 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height()); | 431 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height()); |
434 | 432 |
435 // Shrink the test page. The resize will update the docked panel collection. | 433 // Shrink the test page. The resize will update the docked panel collection. |
436 WaitForAutoResizeNarrower shrink(panel); | 434 WaitForAutoResizeNarrower shrink(panel); |
437 EXPECT_TRUE(content::ExecuteJavaScript( | 435 EXPECT_TRUE(content::ExecuteScript( |
438 panel->GetWebContents()->GetRenderViewHost(), | 436 panel->GetWebContents(), "changeSize(-30);")); |
439 "", | |
440 "changeSize(-30);")); | |
441 shrink.Wait(); | 437 shrink.Wait(); |
442 gfx::Rect bounds_on_shrink = panel->GetBounds(); | 438 gfx::Rect bounds_on_shrink = panel->GetBounds(); |
443 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); | 439 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); |
444 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); | 440 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); |
445 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); | 441 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); |
446 | 442 |
447 // Verify resizing turns off auto-resizing and panel no longer auto-resizes. | 443 // Verify resizing turns off auto-resizing and panel no longer auto-resizes. |
448 gfx::Rect previous_bounds = panel->GetBounds(); | 444 gfx::Rect previous_bounds = panel->GetBounds(); |
449 // These should be identical because the panel is expanded. | 445 // These should be identical because the panel is expanded. |
450 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size()); | 446 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size()); |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 | 1553 |
1558 // Ensure panel has auto resized to original web content size. | 1554 // Ensure panel has auto resized to original web content size. |
1559 WaitForStableInitialSize initial_resize(panel); | 1555 WaitForStableInitialSize initial_resize(panel); |
1560 initial_resize.Wait(); | 1556 initial_resize.Wait(); |
1561 | 1557 |
1562 int initial_width = panel->GetBounds().width(); | 1558 int initial_width = panel->GetBounds().width(); |
1563 int initial_height = panel->GetBounds().height(); | 1559 int initial_height = panel->GetBounds().height(); |
1564 | 1560 |
1565 // Inject some HTML content into the panel. | 1561 // Inject some HTML content into the panel. |
1566 WaitForAutoResizeWider enlarge(panel); | 1562 WaitForAutoResizeWider enlarge(panel); |
1567 EXPECT_TRUE(content::ExecuteJavaScript( | 1563 EXPECT_TRUE(content::ExecuteScript( |
1568 panel->GetWebContents()->GetRenderViewHost(), | 1564 panel->GetWebContents(), |
1569 "", | |
1570 "document.body.innerHTML =" | 1565 "document.body.innerHTML =" |
1571 " '<nobr>line of text and a <button>Button</button>';")); | 1566 " '<nobr>line of text and a <button>Button</button>';")); |
1572 enlarge.Wait(); | 1567 enlarge.Wait(); |
1573 | 1568 |
1574 // The panel should have become larger in both dimensions (the minimums | 1569 // The panel should have become larger in both dimensions (the minimums |
1575 // has to be set to be smaller then a simple 1-line content, so the autosize | 1570 // has to be set to be smaller then a simple 1-line content, so the autosize |
1576 // can work correctly. | 1571 // can work correctly. |
1577 EXPECT_GT(panel->GetBounds().width(), initial_width); | 1572 EXPECT_GT(panel->GetBounds().width(), initial_width); |
1578 EXPECT_GT(panel->GetBounds().height(), initial_height); | 1573 EXPECT_GT(panel->GetBounds().height(), initial_height); |
1579 | 1574 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 #else | 1753 #else |
1759 #define MAYBE_FocusChangeEventOnMinimize FocusChangeEventOnMinimize | 1754 #define MAYBE_FocusChangeEventOnMinimize FocusChangeEventOnMinimize |
1760 #endif | 1755 #endif |
1761 IN_PROC_BROWSER_TEST_F(PanelExtensionApiTest, | 1756 IN_PROC_BROWSER_TEST_F(PanelExtensionApiTest, |
1762 MAYBE_FocusChangeEventOnMinimize) { | 1757 MAYBE_FocusChangeEventOnMinimize) { |
1763 // This is needed so the subsequently created panels can be activated. | 1758 // This is needed so the subsequently created panels can be activated. |
1764 // On a Mac, it transforms background-only test process into foreground one. | 1759 // On a Mac, it transforms background-only test process into foreground one. |
1765 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 1760 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
1766 ASSERT_TRUE(RunExtensionTest("panels/focus_change_on_minimize")) << message_; | 1761 ASSERT_TRUE(RunExtensionTest("panels/focus_change_on_minimize")) << message_; |
1767 } | 1762 } |
OLD | NEW |