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

Side by Side Diff: webkit/tools/test_shell/test_shell_win.cc

Issue 200054: Hook up WebFrameClient, replacing many WebViewDelegate methods.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "webkit/tools/test_shell/test_shell.h" 5 #include "webkit/tools/test_shell/test_shell.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <commdlg.h> 8 #include <commdlg.h>
9 #include <objbase.h> 9 #include <objbase.h>
10 #include <process.h> 10 #include <process.h>
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 kTestWindowXLocation, kTestWindowYLocation, 0, 0, 260 kTestWindowXLocation, kTestWindowYLocation, 0, 0,
261 SWP_NOSIZE | SWP_NOZORDER); 261 SWP_NOSIZE | SWP_NOZORDER);
262 shell->ResizeSubViews(); 262 shell->ResizeSubViews();
263 263
264 if (strstr(params.test_url.c_str(), "loading/") || 264 if (strstr(params.test_url.c_str(), "loading/") ||
265 strstr(params.test_url.c_str(), "loading\\")) 265 strstr(params.test_url.c_str(), "loading\\"))
266 shell->layout_test_controller()->SetShouldDumpFrameLoadCallbacks(true); 266 shell->layout_test_controller()->SetShouldDumpFrameLoadCallbacks(true);
267 267
268 shell->test_is_preparing_ = true; 268 shell->test_is_preparing_ = true;
269 shell->set_test_params(&params); 269 shell->set_test_params(&params);
270 std::wstring wstr = UTF8ToWide(params.test_url.c_str()); 270 shell->LoadURL(GURL(params.test_url));
271 shell->LoadURL(wstr.c_str());
272 271
273 shell->test_is_preparing_ = false; 272 shell->test_is_preparing_ = false;
274 shell->WaitTestFinished(); 273 shell->WaitTestFinished();
275 shell->set_test_params(NULL); 274 shell->set_test_params(NULL);
276 275
277 276
278 return true; 277 return true;
279 } 278 }
280 279
281 std::string TestShell::RewriteLocalUrl(const std::string& url) { 280 std::string TestShell::RewriteLocalUrl(const std::string& url) {
(...skipping 22 matching lines...) Expand all
304 ///////////////////////////////////////////////////////////////////////////// 303 /////////////////////////////////////////////////////////////////////////////
305 // TestShell implementation 304 // TestShell implementation
306 305
307 void TestShell::PlatformCleanUp() { 306 void TestShell::PlatformCleanUp() {
308 // When the window is destroyed, tell the Edit field to forget about us, 307 // When the window is destroyed, tell the Edit field to forget about us,
309 // otherwise we will crash. 308 // otherwise we will crash.
310 win_util::SetWindowProc(m_editWnd, default_edit_wnd_proc_); 309 win_util::SetWindowProc(m_editWnd, default_edit_wnd_proc_);
311 win_util::SetWindowUserData(m_editWnd, NULL); 310 win_util::SetWindowUserData(m_editWnd, NULL);
312 } 311 }
313 312
314 bool TestShell::Initialize(const std::wstring& startingURL) { 313 bool TestShell::Initialize(const GURL& starting_url) {
315 // Perform application initialization: 314 // Perform application initialization:
316 m_mainWnd = CreateWindow(g_windowClass, g_windowTitle, 315 m_mainWnd = CreateWindow(g_windowClass, g_windowTitle,
317 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 316 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
318 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 317 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
319 NULL, NULL, instance_handle_, NULL); 318 NULL, NULL, instance_handle_, NULL);
320 win_util::SetWindowUserData(m_mainWnd, this); 319 win_util::SetWindowUserData(m_mainWnd, this);
321 320
322 HWND hwnd; 321 HWND hwnd;
323 int x = 0; 322 int x = 0;
324 323
(...skipping 30 matching lines...) Expand all
355 default_edit_wnd_proc_ = 354 default_edit_wnd_proc_ =
356 win_util::SetWindowProc(m_editWnd, TestShell::EditWndProc); 355 win_util::SetWindowProc(m_editWnd, TestShell::EditWndProc);
357 win_util::SetWindowUserData(m_editWnd, this); 356 win_util::SetWindowUserData(m_editWnd, this);
358 357
359 // create webview 358 // create webview
360 m_webViewHost.reset( 359 m_webViewHost.reset(
361 WebViewHost::Create(m_mainWnd, delegate_.get(), *TestShell::web_prefs_)); 360 WebViewHost::Create(m_mainWnd, delegate_.get(), *TestShell::web_prefs_));
362 delegate_->RegisterDragDrop(); 361 delegate_->RegisterDragDrop();
363 362
364 // Load our initial content. 363 // Load our initial content.
365 if (!startingURL.empty()) 364 if (starting_url.is_valid())
366 LoadURL(startingURL.c_str()); 365 LoadURL(starting_url);
367 366
368 ShowWindow(webViewWnd(), SW_SHOW); 367 ShowWindow(webViewWnd(), SW_SHOW);
369 368
370 bool bIsSVGTest = startingURL.find(L"W3C-SVG-1.1") != std::wstring::npos; 369 if (IsSVGTestURL(starting_url)) {
371
372 if (bIsSVGTest) {
373 SizeToSVG(); 370 SizeToSVG();
374 } else { 371 } else {
375 SizeToDefault(); 372 SizeToDefault();
376 } 373 }
377 374
378 return true; 375 return true;
379 } 376 }
380 377
381 void TestShell::TestFinished() { 378 void TestShell::TestFinished() {
382 if (!test_is_pending_) 379 if (!test_is_pending_)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 RECT rc; 490 RECT rc;
494 GetClientRect(m_mainWnd, &rc); 491 GetClientRect(m_mainWnd, &rc);
495 492
496 int x = BUTTON_WIDTH * 4; 493 int x = BUTTON_WIDTH * 4;
497 MoveWindow(m_editWnd, x, 0, rc.right - x, URLBAR_HEIGHT, TRUE); 494 MoveWindow(m_editWnd, x, 0, rc.right - x, URLBAR_HEIGHT, TRUE);
498 495
499 MoveWindow(webViewWnd(), 0, URLBAR_HEIGHT, rc.right, 496 MoveWindow(webViewWnd(), 0, URLBAR_HEIGHT, rc.right,
500 rc.bottom - URLBAR_HEIGHT, TRUE); 497 rc.bottom - URLBAR_HEIGHT, TRUE);
501 } 498 }
502 499
503 void TestShell::LoadURLForFrame(const wchar_t* url, 500 void TestShell::LoadURLForFrame(const GURL& url,
504 const wchar_t* frame_name) { 501 const std::wstring& frame_name) {
505 if (!url) 502 if (!url.is_valid())
506 return; 503 return;
507 504
508 TRACE_EVENT_BEGIN("url.load", this, WideToUTF8(url)); 505 TRACE_EVENT_BEGIN("url.load", this, url.spec());
509 bool bIsSVGTest = wcsstr(url, L"W3C-SVG-1.1") > 0;
510 506
511 if (bIsSVGTest) { 507 if (IsSVGTestURL(url)) {
512 SizeToSVG(); 508 SizeToSVG();
513 } else { 509 } else {
514 // only resize back to the default when running tests 510 // only resize back to the default when running tests
515 if (layout_test_mode()) 511 if (layout_test_mode())
516 SizeToDefault(); 512 SizeToDefault();
517 } 513 }
518 514
519 std::wstring urlString(url); 515 navigation_controller_->LoadEntry(
520 if (!urlString.empty() && (PathFileExists(url) || PathIsUNC(url))) { 516 new TestNavigationEntry(-1, url, std::wstring(), frame_name));
521 wchar_t fileURL[INTERNET_MAX_URL_LENGTH];
522 DWORD fileURLLength = INTERNET_MAX_URL_LENGTH;
523 if (SUCCEEDED(UrlCreateFromPath(url, fileURL, &fileURLLength, 0)))
524 urlString.assign(fileURL);
525 }
526
527 std::wstring frame_string;
528 if (frame_name)
529 frame_string = frame_name;
530
531 navigation_controller_->LoadEntry(new TestNavigationEntry(
532 -1, GURL(urlString), std::wstring(), frame_string));
533 } 517 }
534 518
535 LRESULT CALLBACK TestShell::WndProc(HWND hwnd, UINT message, WPARAM wParam, 519 LRESULT CALLBACK TestShell::WndProc(HWND hwnd, UINT message, WPARAM wParam,
536 LPARAM lParam) { 520 LPARAM lParam) {
537 TestShell* shell = static_cast<TestShell*>(win_util::GetWindowUserData(hwnd)); 521 TestShell* shell = static_cast<TestShell*>(win_util::GetWindowUserData(hwnd));
538 522
539 switch (message) { 523 switch (message) {
540 case WM_COMMAND: 524 case WM_COMMAND:
541 { 525 {
542 int wmId = LOWORD(wParam); 526 int wmId = LOWORD(wParam);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 #define MAX_URL_LENGTH 1024 589 #define MAX_URL_LENGTH 1024
606 590
607 LRESULT CALLBACK TestShell::EditWndProc(HWND hwnd, UINT message, 591 LRESULT CALLBACK TestShell::EditWndProc(HWND hwnd, UINT message,
608 WPARAM wParam, LPARAM lParam) { 592 WPARAM wParam, LPARAM lParam) {
609 TestShell* shell = 593 TestShell* shell =
610 static_cast<TestShell*>(win_util::GetWindowUserData(hwnd)); 594 static_cast<TestShell*>(win_util::GetWindowUserData(hwnd));
611 595
612 switch (message) { 596 switch (message) {
613 case WM_CHAR: 597 case WM_CHAR:
614 if (wParam == VK_RETURN) { 598 if (wParam == VK_RETURN) {
615 wchar_t strPtr[MAX_URL_LENGTH + 1]; // Leave room for adding a NULL; 599 wchar_t str[MAX_URL_LENGTH + 1]; // Leave room for adding a NULL;
616 *((LPWORD)strPtr) = MAX_URL_LENGTH; 600 *((LPWORD)str) = MAX_URL_LENGTH;
617 LRESULT strLen = SendMessage(hwnd, EM_GETLINE, 0, (LPARAM)strPtr); 601 LRESULT str_len = SendMessage(hwnd, EM_GETLINE, 0, (LPARAM)str);
618 if (strLen > 0) { 602 if (str_len > 0) {
619 strPtr[strLen] = 0; // EM_GETLINE doesn't NULL terminate. 603 str[str_len] = 0; // EM_GETLINE doesn't NULL terminate.
620 shell->LoadURL(strPtr); 604 shell->LoadURL(GURL(str));
621 } 605 }
622 606
623 return 0; 607 return 0;
624 } 608 }
625 } 609 }
626 610
627 return (LRESULT) CallWindowProc(shell->default_edit_wnd_proc_, hwnd, 611 return (LRESULT) CallWindowProc(shell->default_edit_wnd_proc_, hwnd,
628 message, wParam, lParam); 612 message, wParam, lParam);
629 } 613 }
630 614
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 743
760 bool EnsureFontLoaded(HFONT font) { 744 bool EnsureFontLoaded(HFONT font) {
761 return true; 745 return true;
762 } 746 }
763 747
764 bool DownloadUrl(const std::string& url, HWND caller_window) { 748 bool DownloadUrl(const std::string& url, HWND caller_window) {
765 return false; 749 return false;
766 } 750 }
767 751
768 } // namespace webkit_glue 752 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell_test.cc ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698