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

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

Issue 10795090: Move ExecuteJavaScript functions from ui_test_utils.h to browser_test_utils.h so they can be reused… (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 18 matching lines...) Expand all
29 #include "chrome/browser/web_applications/web_app.h" 29 #include "chrome/browser/web_applications/web_app.h"
30 #include "chrome/common/chrome_notification_types.h" 30 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/extensions/extension_manifest_constants.h" 31 #include "chrome/common/extensions/extension_manifest_constants.h"
32 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
33 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
34 #include "chrome/test/base/ui_test_utils.h" 34 #include "chrome/test/base/ui_test_utils.h"
35 #include "content/public/browser/download_manager.h" 35 #include "content/public/browser/download_manager.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
38 #include "content/public/common/url_constants.h" 38 #include "content/public/common/url_constants.h"
39 #include "content/public/test/browser_test_utils.h"
39 #include "content/test/net/url_request_mock_http_job.h" 40 #include "content/test/net/url_request_mock_http_job.h"
40 #include "net/base/net_util.h" 41 #include "net/base/net_util.h"
41 #include "testing/gtest/include/gtest/gtest.h" 42 #include "testing/gtest/include/gtest/gtest.h"
42 #include "ui/gfx/screen.h" 43 #include "ui/gfx/screen.h"
43 44
44 // Refactor has only been done for Win and Mac panels so far. 45 // Refactor has only been done for Win and Mac panels so far.
45 #if defined(OS_WIN) || defined(OS_MACOSX) 46 #if defined(OS_WIN) || defined(OS_MACOSX)
46 47
47 using content::BrowserContext; 48 using content::BrowserContext;
48 using content::BrowserThread; 49 using content::BrowserThread;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 FilePath(kTestDir), 371 FilePath(kTestDir),
371 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 372 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
372 params.url = url; 373 params.url = url;
373 Panel* panel = CreatePanelWithParams(params); 374 Panel* panel = CreatePanelWithParams(params);
374 375
375 // Expand the test page. The resize will update the docked panel strip. 376 // Expand the test page. The resize will update the docked panel strip.
376 gfx::Rect initial_bounds = panel->GetBounds(); 377 gfx::Rect initial_bounds = panel->GetBounds();
377 content::WindowedNotificationObserver enlarge( 378 content::WindowedNotificationObserver enlarge(
378 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, 379 chrome::NOTIFICATION_PANEL_STRIP_UPDATED,
379 content::NotificationService::AllSources()); 380 content::NotificationService::AllSources());
380 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 381 EXPECT_TRUE(content::ExecuteJavaScript(
381 panel->GetWebContents()->GetRenderViewHost(), 382 panel->GetWebContents()->GetRenderViewHost(),
382 std::wstring(), 383 std::wstring(),
383 L"changeSize(50);")); 384 L"changeSize(50);"));
384 enlarge.Wait(); 385 enlarge.Wait();
385 gfx::Rect bounds_on_grow = panel->GetBounds(); 386 gfx::Rect bounds_on_grow = panel->GetBounds();
386 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); 387 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width());
387 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height()); 388 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height());
388 389
389 // Shrink the test page. The resize will update the docked panel strip. 390 // Shrink the test page. The resize will update the docked panel strip.
390 content::WindowedNotificationObserver shrink( 391 content::WindowedNotificationObserver shrink(
391 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, 392 chrome::NOTIFICATION_PANEL_STRIP_UPDATED,
392 content::NotificationService::AllSources()); 393 content::NotificationService::AllSources());
393 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 394 EXPECT_TRUE(content::ExecuteJavaScript(
394 panel->GetWebContents()->GetRenderViewHost(), 395 panel->GetWebContents()->GetRenderViewHost(),
395 std::wstring(), 396 std::wstring(),
396 L"changeSize(-30);")); 397 L"changeSize(-30);"));
397 shrink.Wait(); 398 shrink.Wait();
398 gfx::Rect bounds_on_shrink = panel->GetBounds(); 399 gfx::Rect bounds_on_shrink = panel->GetBounds();
399 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); 400 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width());
400 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); 401 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width());
401 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); 402 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height());
402 403
403 // Verify resizing turns off auto-resizing and panel no longer auto-resizes. 404 // Verify resizing turns off auto-resizing and panel no longer auto-resizes.
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>"); 1494 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>");
1494 Panel* panel = CreatePanelWithParams(params); 1495 Panel* panel = CreatePanelWithParams(params);
1495 1496
1496 int initial_width = panel->GetBounds().width(); 1497 int initial_width = panel->GetBounds().width();
1497 int initial_height = panel->GetBounds().height(); 1498 int initial_height = panel->GetBounds().height();
1498 1499
1499 // Inject some HTML content into the panel. 1500 // Inject some HTML content into the panel.
1500 content::WindowedNotificationObserver enlarge( 1501 content::WindowedNotificationObserver enlarge(
1501 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 1502 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
1502 content::Source<Panel>(panel)); 1503 content::Source<Panel>(panel));
1503 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 1504 EXPECT_TRUE(content::ExecuteJavaScript(
1504 panel->GetWebContents()->GetRenderViewHost(), 1505 panel->GetWebContents()->GetRenderViewHost(),
1505 std::wstring(), 1506 std::wstring(),
1506 L"document.body.innerHTML =" 1507 L"document.body.innerHTML ="
1507 L"'<nobr>line of text and a <button>Button</button>';")); 1508 L"'<nobr>line of text and a <button>Button</button>';"));
1508 enlarge.Wait(); 1509 enlarge.Wait();
1509 1510
1510 // The panel should have become larger in both dimensions (the minimums 1511 // The panel should have become larger in both dimensions (the minimums
1511 // has to be set to be smaller then a simple 1-line content, so the autosize 1512 // has to be set to be smaller then a simple 1-line content, so the autosize
1512 // can work correctly. 1513 // can work correctly.
1513 EXPECT_GT(panel->GetBounds().width(), initial_width); 1514 EXPECT_GT(panel->GetBounds().width(), initial_width);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 EXPECT_GT(old_full_size.width(), panel->full_size().width()); 1572 EXPECT_GT(old_full_size.width(), panel->full_size().width());
1572 EXPECT_GT(old_full_size.height(), panel->full_size().height()); 1573 EXPECT_GT(old_full_size.height(), panel->full_size().height());
1573 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); 1574 EXPECT_GE(panel->max_size().width(), panel->full_size().width());
1574 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); 1575 EXPECT_GE(panel->max_size().height(), panel->full_size().height());
1575 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); 1576 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height());
1576 1577
1577 panel->Close(); 1578 panel->Close();
1578 } 1579 }
1579 1580
1580 #endif // OS_WIN || OS_MACOSX 1581 #endif // OS_WIN || OS_MACOSX
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/old_panel_browsertest.cc ('k') | chrome/browser/ui/pdf/pdf_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698