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

Side by Side Diff: chrome/browser/ui/panels/old_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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // Create a test panel with tab contents loaded. 360 // Create a test panel with tab contents loaded.
361 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); 361 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE);
362 GURL url(ui_test_utils::GetTestUrl( 362 GURL url(ui_test_utils::GetTestUrl(
363 FilePath(kTestDir), 363 FilePath(kTestDir),
364 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 364 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
365 params.url = url; 365 params.url = url;
366 Panel* panel = CreatePanelWithParams(params); 366 Panel* panel = CreatePanelWithParams(params);
367 367
368 // Expand the test page. 368 // Expand the test page.
369 gfx::Rect initial_bounds = panel->GetBounds(); 369 gfx::Rect initial_bounds = panel->GetBounds();
370 ui_test_utils::WindowedNotificationObserver enlarge( 370 content::WindowedNotificationObserver enlarge(
371 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 371 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
372 content::Source<Panel>(panel)); 372 content::Source<Panel>(panel));
373 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 373 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
374 panel->GetWebContents()->GetRenderViewHost(), 374 panel->GetWebContents()->GetRenderViewHost(),
375 std::wstring(), 375 std::wstring(),
376 L"changeSize(50);")); 376 L"changeSize(50);"));
377 enlarge.Wait(); 377 enlarge.Wait();
378 gfx::Rect bounds_on_grow = panel->GetBounds(); 378 gfx::Rect bounds_on_grow = panel->GetBounds();
379 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); 379 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width());
380 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height()); 380 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height());
381 381
382 // Shrink the test page. 382 // Shrink the test page.
383 ui_test_utils::WindowedNotificationObserver shrink( 383 content::WindowedNotificationObserver shrink(
384 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 384 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
385 content::Source<Panel>(panel)); 385 content::Source<Panel>(panel));
386 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 386 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
387 panel->GetWebContents()->GetRenderViewHost(), 387 panel->GetWebContents()->GetRenderViewHost(),
388 std::wstring(), 388 std::wstring(),
389 L"changeSize(-30);")); 389 L"changeSize(-30);"));
390 shrink.Wait(); 390 shrink.Wait();
391 gfx::Rect bounds_on_shrink = panel->GetBounds(); 391 gfx::Rect bounds_on_shrink = panel->GetBounds();
392 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); 392 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width());
393 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); 393 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width());
394 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); 394 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height());
395 395
396 // Verify resizing turns off auto-resizing and that it works. 396 // Verify resizing turns off auto-resizing and that it works.
397 gfx::Rect previous_bounds = panel->GetBounds(); 397 gfx::Rect previous_bounds = panel->GetBounds();
398 // These should be identical because the panel is expanded. 398 // These should be identical because the panel is expanded.
399 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size()); 399 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size());
400 gfx::Size new_size(previous_bounds.size()); 400 gfx::Size new_size(previous_bounds.size());
401 new_size.Enlarge(5, 5); 401 new_size.Enlarge(5, 5);
402 gfx::Rect new_bounds(previous_bounds.origin(), new_size); 402 gfx::Rect new_bounds(previous_bounds.origin(), new_size);
403 panel->SetBounds(new_bounds); 403 panel->SetBounds(new_bounds);
404 EXPECT_FALSE(panel->auto_resizable()); 404 EXPECT_FALSE(panel->auto_resizable());
405 EXPECT_EQ(new_bounds.size(), panel->GetBounds().size()); 405 EXPECT_EQ(new_bounds.size(), panel->GetBounds().size());
406 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size()); 406 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size());
407 407
408 // Turn back on auto-resize and verify that it works. 408 // Turn back on auto-resize and verify that it works.
409 ui_test_utils::WindowedNotificationObserver auto_resize_enabled( 409 content::WindowedNotificationObserver auto_resize_enabled(
410 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 410 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
411 content::Source<Panel>(panel)); 411 content::Source<Panel>(panel));
412 panel->SetAutoResizable(true); 412 panel->SetAutoResizable(true);
413 auto_resize_enabled.Wait(); 413 auto_resize_enabled.Wait();
414 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds(); 414 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds();
415 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width()); 415 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width());
416 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height()); 416 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height());
417 417
418 panel->Close(); 418 panel->Close();
419 } 419 }
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 1253
1254 // When there are 2 panels and no chrome window, minimizing one panel does 1254 // When there are 2 panels and no chrome window, minimizing one panel does
1255 // not expand/focuses another. 1255 // not expand/focuses another.
1256 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, 1256 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest,
1257 MAYBE_MinimizeTwoPanelsWithoutTabbedWindow) { 1257 MAYBE_MinimizeTwoPanelsWithoutTabbedWindow) {
1258 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); 1258 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE);
1259 Panel* panel1 = CreatePanelWithParams(params); 1259 Panel* panel1 = CreatePanelWithParams(params);
1260 Panel* panel2 = CreatePanelWithParams(params); 1260 Panel* panel2 = CreatePanelWithParams(params);
1261 1261
1262 // Close main tabbed window. 1262 // Close main tabbed window.
1263 ui_test_utils::WindowedNotificationObserver signal( 1263 content::WindowedNotificationObserver signal(
1264 chrome::NOTIFICATION_BROWSER_CLOSED, 1264 chrome::NOTIFICATION_BROWSER_CLOSED,
1265 content::Source<Browser>(browser())); 1265 content::Source<Browser>(browser()));
1266 chrome::CloseWindow(browser()); 1266 chrome::CloseWindow(browser());
1267 signal.Wait(); 1267 signal.Wait();
1268 1268
1269 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 1269 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
1270 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); 1270 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
1271 panel1->Activate(); 1271 panel1->Activate();
1272 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); 1272 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE);
1273 1273
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 EXPECT_EQ(2, panel_manager->num_panels()); 1330 EXPECT_EQ(2, panel_manager->num_panels());
1331 1331
1332 // Create another extension and a panel from that extension. 1332 // Create another extension and a panel from that extension.
1333 scoped_refptr<Extension> extension_other = 1333 scoped_refptr<Extension> extension_other =
1334 CreateExtension(FILE_PATH_LITERAL("TestExtensionOther"), 1334 CreateExtension(FILE_PATH_LITERAL("TestExtensionOther"),
1335 Extension::INVALID, empty_value); 1335 Extension::INVALID, empty_value);
1336 std::string extension_app_name_other = 1336 std::string extension_app_name_other =
1337 web_app::GenerateApplicationNameFromExtensionId(extension_other->id()); 1337 web_app::GenerateApplicationNameFromExtensionId(extension_other->id());
1338 Panel* panel_other = CreatePanel(extension_app_name_other); 1338 Panel* panel_other = CreatePanel(extension_app_name_other);
1339 1339
1340 ui_test_utils::WindowedNotificationObserver signal( 1340 content::WindowedNotificationObserver signal(
1341 chrome::NOTIFICATION_PANEL_CLOSED, 1341 chrome::NOTIFICATION_PANEL_CLOSED,
1342 content::Source<Panel>(panel)); 1342 content::Source<Panel>(panel));
1343 ui_test_utils::WindowedNotificationObserver signal1( 1343 content::WindowedNotificationObserver signal1(
1344 chrome::NOTIFICATION_PANEL_CLOSED, 1344 chrome::NOTIFICATION_PANEL_CLOSED,
1345 content::Source<Panel>(panel1)); 1345 content::Source<Panel>(panel1));
1346 1346
1347 // Send unload notification on the first extension. 1347 // Send unload notification on the first extension.
1348 extensions::UnloadedExtensionInfo details(extension, 1348 extensions::UnloadedExtensionInfo details(extension,
1349 extension_misc::UNLOAD_REASON_UNINSTALL); 1349 extension_misc::UNLOAD_REASON_UNINSTALL);
1350 content::NotificationService::current()->Notify( 1350 content::NotificationService::current()->Notify(
1351 chrome::NOTIFICATION_EXTENSION_UNLOADED, 1351 chrome::NOTIFICATION_EXTENSION_UNLOADED,
1352 content::Source<Profile>(browser()->profile()), 1352 content::Source<Profile>(browser()->profile()),
1353 content::Details<extensions::UnloadedExtensionInfo>(&details)); 1353 content::Details<extensions::UnloadedExtensionInfo>(&details));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 title_watcher.reset( 1393 title_watcher.reset(
1394 new ui_test_utils::TitleWatcher(web_contents, title_second_close)); 1394 new ui_test_utils::TitleWatcher(web_contents, title_second_close));
1395 panel->Close(); 1395 panel->Close();
1396 alert = ui_test_utils::WaitForAppModalDialog(); 1396 alert = ui_test_utils::WaitForAppModalDialog();
1397 alert->native_dialog()->CloseAppModalDialog(); 1397 alert->native_dialog()->CloseAppModalDialog();
1398 EXPECT_EQ(title_second_close, title_watcher->WaitAndGetTitle()); 1398 EXPECT_EQ(title_second_close, title_watcher->WaitAndGetTitle());
1399 EXPECT_EQ(1, panel_manager->num_panels()); 1399 EXPECT_EQ(1, panel_manager->num_panels());
1400 1400
1401 // Close panel and respond to the onbeforeunload dialog with accept. This is 1401 // Close panel and respond to the onbeforeunload dialog with accept. This is
1402 // equivalent to clicking "Leave this page". 1402 // equivalent to clicking "Leave this page".
1403 ui_test_utils::WindowedNotificationObserver signal( 1403 content::WindowedNotificationObserver signal(
1404 chrome::NOTIFICATION_PANEL_CLOSED, 1404 chrome::NOTIFICATION_PANEL_CLOSED,
1405 content::Source<Panel>(panel)); 1405 content::Source<Panel>(panel));
1406 panel->Close(); 1406 panel->Close();
1407 alert = ui_test_utils::WaitForAppModalDialog(); 1407 alert = ui_test_utils::WaitForAppModalDialog();
1408 alert->native_dialog()->AcceptAppModalDialog(); 1408 alert->native_dialog()->AcceptAppModalDialog();
1409 signal.Wait(); 1409 signal.Wait();
1410 EXPECT_EQ(0, panel_manager->num_panels()); 1410 EXPECT_EQ(0, panel_manager->num_panels());
1411 } 1411 }
1412 1412
1413 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, SizeClamping) { 1413 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, SizeClamping) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 PanelManager::GetInstance()->enable_auto_sizing(true); 1446 PanelManager::GetInstance()->enable_auto_sizing(true);
1447 // Using 0 sizes triggers auto-sizing. 1447 // Using 0 sizes triggers auto-sizing.
1448 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE); 1448 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE);
1449 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>"); 1449 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>");
1450 Panel* panel = CreatePanelWithParams(params); 1450 Panel* panel = CreatePanelWithParams(params);
1451 1451
1452 int initial_width = panel->GetBounds().width(); 1452 int initial_width = panel->GetBounds().width();
1453 int initial_height = panel->GetBounds().height(); 1453 int initial_height = panel->GetBounds().height();
1454 1454
1455 // Inject some HTML content into the panel. 1455 // Inject some HTML content into the panel.
1456 ui_test_utils::WindowedNotificationObserver enlarge( 1456 content::WindowedNotificationObserver enlarge(
1457 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 1457 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
1458 content::Source<Panel>(panel)); 1458 content::Source<Panel>(panel));
1459 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 1459 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
1460 panel->GetWebContents()->GetRenderViewHost(), 1460 panel->GetWebContents()->GetRenderViewHost(),
1461 std::wstring(), 1461 std::wstring(),
1462 L"document.body.innerHTML =" 1462 L"document.body.innerHTML ="
1463 L"'<nobr>line of text and a <button>Button</button>';")); 1463 L"'<nobr>line of text and a <button>Button</button>';"));
1464 enlarge.Wait(); 1464 enlarge.Wait();
1465 1465
1466 // The panel should have become larger in both dimensions (the minimums 1466 // The panel should have become larger in both dimensions (the minimums
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 EXPECT_GE(smaller_work_area_size.width(), panel->max_size().width()); 1525 EXPECT_GE(smaller_work_area_size.width(), panel->max_size().width());
1526 EXPECT_EQ(smaller_work_area_size.height(), panel->max_size().height()); 1526 EXPECT_EQ(smaller_work_area_size.height(), panel->max_size().height());
1527 EXPECT_GT(old_full_size.width(), panel->full_size().width()); 1527 EXPECT_GT(old_full_size.width(), panel->full_size().width());
1528 EXPECT_GT(old_full_size.height(), panel->full_size().height()); 1528 EXPECT_GT(old_full_size.height(), panel->full_size().height());
1529 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); 1529 EXPECT_GE(panel->max_size().width(), panel->full_size().width());
1530 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); 1530 EXPECT_GE(panel->max_size().height(), panel->full_size().height());
1531 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); 1531 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height());
1532 1532
1533 panel->Close(); 1533 panel->Close();
1534 } 1534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698