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

Side by Side Diff: chrome/browser/ui/panels/panel_browsertest.cc

Issue 10807047: Create content\public\test\test_utils.h to hold common test classes that are used by unit and brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/bind.h" 5 #include "base/bind.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/download/download_service.h" 7 #include "chrome/browser/download/download_service.h"
8 #include "chrome/browser/download/download_service_factory.h" 8 #include "chrome/browser/download/download_service_factory.h"
9 #include "chrome/browser/net/url_request_mock_util.h" 9 #include "chrome/browser/net/url_request_mock_util.h"
10 #include "chrome/browser/prefs/browser_prefs.h" 10 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // Create a test panel with web contents loaded. 367 // Create a test panel with web contents loaded.
368 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); 368 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE);
369 GURL url(ui_test_utils::GetTestUrl( 369 GURL url(ui_test_utils::GetTestUrl(
370 FilePath(kTestDir), 370 FilePath(kTestDir),
371 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 371 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
372 params.url = url; 372 params.url = url;
373 Panel* panel = CreatePanelWithParams(params); 373 Panel* panel = CreatePanelWithParams(params);
374 374
375 // Expand the test page. The resize will update the docked panel strip. 375 // Expand the test page. The resize will update the docked panel strip.
376 gfx::Rect initial_bounds = panel->GetBounds(); 376 gfx::Rect initial_bounds = panel->GetBounds();
377 ui_test_utils::WindowedNotificationObserver enlarge( 377 content::WindowedNotificationObserver enlarge(
378 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, 378 chrome::NOTIFICATION_PANEL_STRIP_UPDATED,
379 content::NotificationService::AllSources()); 379 content::NotificationService::AllSources());
380 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 380 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
381 panel->GetWebContents()->GetRenderViewHost(), 381 panel->GetWebContents()->GetRenderViewHost(),
382 std::wstring(), 382 std::wstring(),
383 L"changeSize(50);")); 383 L"changeSize(50);"));
384 enlarge.Wait(); 384 enlarge.Wait();
385 gfx::Rect bounds_on_grow = panel->GetBounds(); 385 gfx::Rect bounds_on_grow = panel->GetBounds();
386 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); 386 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width());
387 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height()); 387 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height());
388 388
389 // Shrink the test page. The resize will update the docked panel strip. 389 // Shrink the test page. The resize will update the docked panel strip.
390 ui_test_utils::WindowedNotificationObserver shrink( 390 content::WindowedNotificationObserver shrink(
391 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, 391 chrome::NOTIFICATION_PANEL_STRIP_UPDATED,
392 content::NotificationService::AllSources()); 392 content::NotificationService::AllSources());
393 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 393 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
394 panel->GetWebContents()->GetRenderViewHost(), 394 panel->GetWebContents()->GetRenderViewHost(),
395 std::wstring(), 395 std::wstring(),
396 L"changeSize(-30);")); 396 L"changeSize(-30);"));
397 shrink.Wait(); 397 shrink.Wait();
398 gfx::Rect bounds_on_shrink = panel->GetBounds(); 398 gfx::Rect bounds_on_shrink = panel->GetBounds();
399 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); 399 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width());
400 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); 400 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width());
401 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); 401 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height());
402 402
403 // Verify resizing turns off auto-resizing and panel no longer auto-resizes. 403 // Verify resizing turns off auto-resizing and panel no longer auto-resizes.
404 gfx::Rect previous_bounds = panel->GetBounds(); 404 gfx::Rect previous_bounds = panel->GetBounds();
405 // These should be identical because the panel is expanded. 405 // These should be identical because the panel is expanded.
406 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size()); 406 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size());
407 gfx::Size new_size(previous_bounds.size()); 407 gfx::Size new_size(previous_bounds.size());
408 new_size.Enlarge(5, 5); 408 new_size.Enlarge(5, 5);
409 gfx::Rect new_bounds(previous_bounds.origin(), new_size); 409 gfx::Rect new_bounds(previous_bounds.origin(), new_size);
410 panel->SetBounds(new_bounds); 410 panel->SetBounds(new_bounds);
411 EXPECT_FALSE(panel->auto_resizable()); 411 EXPECT_FALSE(panel->auto_resizable());
412 EXPECT_EQ(new_bounds.size(), panel->GetBounds().size()); 412 EXPECT_EQ(new_bounds.size(), panel->GetBounds().size());
413 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size()); 413 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size());
414 414
415 // Turn back on auto-resize and verify that panel auto resizes. 415 // Turn back on auto-resize and verify that panel auto resizes.
416 ui_test_utils::WindowedNotificationObserver auto_resize_enabled( 416 content::WindowedNotificationObserver auto_resize_enabled(
417 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, 417 chrome::NOTIFICATION_PANEL_STRIP_UPDATED,
418 content::NotificationService::AllSources()); 418 content::NotificationService::AllSources());
419 panel->SetAutoResizable(true); 419 panel->SetAutoResizable(true);
420 auto_resize_enabled.Wait(); 420 auto_resize_enabled.Wait();
421 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds(); 421 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds();
422 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width()); 422 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width());
423 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height()); 423 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height());
424 424
425 panel->Close(); 425 panel->Close();
426 } 426 }
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 1331
1332 // When there are 2 panels and no chrome window, minimizing one panel does 1332 // When there are 2 panels and no chrome window, minimizing one panel does
1333 // not expand/focuses another. 1333 // not expand/focuses another.
1334 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, 1334 IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
1335 MAYBE_MinimizeTwoPanelsWithoutTabbedWindow) { 1335 MAYBE_MinimizeTwoPanelsWithoutTabbedWindow) {
1336 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); 1336 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE);
1337 Panel* panel1 = CreatePanelWithParams(params); 1337 Panel* panel1 = CreatePanelWithParams(params);
1338 Panel* panel2 = CreatePanelWithParams(params); 1338 Panel* panel2 = CreatePanelWithParams(params);
1339 1339
1340 // Close main tabbed window. 1340 // Close main tabbed window.
1341 ui_test_utils::WindowedNotificationObserver signal( 1341 content::WindowedNotificationObserver signal(
1342 chrome::NOTIFICATION_BROWSER_CLOSED, 1342 chrome::NOTIFICATION_BROWSER_CLOSED,
1343 content::Source<Browser>(browser())); 1343 content::Source<Browser>(browser()));
1344 chrome::CloseWindow(browser()); 1344 chrome::CloseWindow(browser());
1345 signal.Wait(); 1345 signal.Wait();
1346 1346
1347 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 1347 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
1348 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); 1348 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
1349 panel1->Activate(); 1349 panel1->Activate();
1350 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); 1350 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE);
1351 1351
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 EXPECT_EQ(2, panel_manager->num_panels()); 1401 EXPECT_EQ(2, panel_manager->num_panels());
1402 1402
1403 // Create another extension and a panel from that extension. 1403 // Create another extension and a panel from that extension.
1404 scoped_refptr<Extension> extension_other = 1404 scoped_refptr<Extension> extension_other =
1405 CreateExtension(FILE_PATH_LITERAL("TestExtensionOther"), 1405 CreateExtension(FILE_PATH_LITERAL("TestExtensionOther"),
1406 Extension::INVALID, empty_value); 1406 Extension::INVALID, empty_value);
1407 std::string extension_app_name_other = 1407 std::string extension_app_name_other =
1408 web_app::GenerateApplicationNameFromExtensionId(extension_other->id()); 1408 web_app::GenerateApplicationNameFromExtensionId(extension_other->id());
1409 Panel* panel_other = CreatePanel(extension_app_name_other); 1409 Panel* panel_other = CreatePanel(extension_app_name_other);
1410 1410
1411 ui_test_utils::WindowedNotificationObserver signal( 1411 content::WindowedNotificationObserver signal(
1412 chrome::NOTIFICATION_PANEL_CLOSED, 1412 chrome::NOTIFICATION_PANEL_CLOSED,
1413 content::Source<Panel>(panel)); 1413 content::Source<Panel>(panel));
1414 ui_test_utils::WindowedNotificationObserver signal1( 1414 content::WindowedNotificationObserver signal1(
1415 chrome::NOTIFICATION_PANEL_CLOSED, 1415 chrome::NOTIFICATION_PANEL_CLOSED,
1416 content::Source<Panel>(panel1)); 1416 content::Source<Panel>(panel1));
1417 1417
1418 // Send unload notification on the first extension. 1418 // Send unload notification on the first extension.
1419 extensions::UnloadedExtensionInfo details(extension, 1419 extensions::UnloadedExtensionInfo details(extension,
1420 extension_misc::UNLOAD_REASON_UNINSTALL); 1420 extension_misc::UNLOAD_REASON_UNINSTALL);
1421 content::NotificationService::current()->Notify( 1421 content::NotificationService::current()->Notify(
1422 chrome::NOTIFICATION_EXTENSION_UNLOADED, 1422 chrome::NOTIFICATION_EXTENSION_UNLOADED,
1423 content::Source<Profile>(browser()->profile()), 1423 content::Source<Profile>(browser()->profile()),
1424 content::Details<extensions::UnloadedExtensionInfo>(&details)); 1424 content::Details<extensions::UnloadedExtensionInfo>(&details));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 PanelManager::GetInstance()->enable_auto_sizing(true); 1490 PanelManager::GetInstance()->enable_auto_sizing(true);
1491 // Using 0 sizes triggers auto-sizing. 1491 // Using 0 sizes triggers auto-sizing.
1492 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE); 1492 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE);
1493 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>"); 1493 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>");
1494 Panel* panel = CreatePanelWithParams(params); 1494 Panel* panel = CreatePanelWithParams(params);
1495 1495
1496 int initial_width = panel->GetBounds().width(); 1496 int initial_width = panel->GetBounds().width();
1497 int initial_height = panel->GetBounds().height(); 1497 int initial_height = panel->GetBounds().height();
1498 1498
1499 // Inject some HTML content into the panel. 1499 // Inject some HTML content into the panel.
1500 ui_test_utils::WindowedNotificationObserver enlarge( 1500 content::WindowedNotificationObserver enlarge(
1501 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 1501 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
1502 content::Source<Panel>(panel)); 1502 content::Source<Panel>(panel));
1503 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 1503 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
1504 panel->GetWebContents()->GetRenderViewHost(), 1504 panel->GetWebContents()->GetRenderViewHost(),
1505 std::wstring(), 1505 std::wstring(),
1506 L"document.body.innerHTML =" 1506 L"document.body.innerHTML ="
1507 L"'<nobr>line of text and a <button>Button</button>';")); 1507 L"'<nobr>line of text and a <button>Button</button>';"));
1508 enlarge.Wait(); 1508 enlarge.Wait();
1509 1509
1510 // The panel should have become larger in both dimensions (the minimums 1510 // The panel should have become larger in both dimensions (the minimums
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 EXPECT_GT(old_full_size.width(), panel->full_size().width()); 1571 EXPECT_GT(old_full_size.width(), panel->full_size().width());
1572 EXPECT_GT(old_full_size.height(), panel->full_size().height()); 1572 EXPECT_GT(old_full_size.height(), panel->full_size().height());
1573 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); 1573 EXPECT_GE(panel->max_size().width(), panel->full_size().width());
1574 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); 1574 EXPECT_GE(panel->max_size().height(), panel->full_size().height());
1575 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); 1575 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height());
1576 1576
1577 panel->Close(); 1577 panel->Close();
1578 } 1578 }
1579 1579
1580 #endif // OS_WIN || OS_MACOSX 1580 #endif // OS_WIN || OS_MACOSX
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm ('k') | chrome/browser/ui/panels/panel_cocoa_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698