OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <ApplicationServices/ApplicationServices.h> | 5 #include <ApplicationServices/ApplicationServices.h> |
6 #import <Cocoa/Cocoa.h> | 6 #import <Cocoa/Cocoa.h> |
7 #import <objc/objc-runtime.h> | 7 #import <objc/objc-runtime.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include "webkit/tools/test_shell/test_shell.h" | 10 #include "webkit/tools/test_shell/test_shell.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 NSButton* MakeTestButton(NSRect* rect, NSString* title, NSView* parent) { | 218 NSButton* MakeTestButton(NSRect* rect, NSString* title, NSView* parent) { |
219 NSButton* button = [[[NSButton alloc] initWithFrame:*rect] autorelease]; | 219 NSButton* button = [[[NSButton alloc] initWithFrame:*rect] autorelease]; |
220 [button setTitle:title]; | 220 [button setTitle:title]; |
221 [button setBezelStyle:NSSmallSquareBezelStyle]; | 221 [button setBezelStyle:NSSmallSquareBezelStyle]; |
222 [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; | 222 [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; |
223 [parent addSubview:button]; | 223 [parent addSubview:button]; |
224 rect->origin.x += BUTTON_WIDTH; | 224 rect->origin.x += BUTTON_WIDTH; |
225 return button; | 225 return button; |
226 } | 226 } |
227 | 227 |
228 bool TestShell::Initialize(const std::wstring& startingURL) { | 228 bool TestShell::Initialize(const GURL& starting_url) { |
229 // Perform application initialization: | 229 // Perform application initialization: |
230 // send message to app controller? need to work this out | 230 // send message to app controller? need to work this out |
231 | 231 |
232 // TODO(awalker): this is a straight recreation of windows test_shell.cc's | 232 // TODO(awalker): this is a straight recreation of windows test_shell.cc's |
233 // window creation code--we should really pull this from the nib and grab | 233 // window creation code--we should really pull this from the nib and grab |
234 // references to the already-created subviews that way. | 234 // references to the already-created subviews that way. |
235 NSRect screen_rect = [[NSScreen mainScreen] visibleFrame]; | 235 NSRect screen_rect = [[NSScreen mainScreen] visibleFrame]; |
236 NSRect window_rect = { {0, screen_rect.size.height - kTestWindowHeight}, | 236 NSRect window_rect = { {0, screen_rect.size.height - kTestWindowHeight}, |
237 {kTestWindowWidth, kTestWindowHeight} }; | 237 {kTestWindowWidth, kTestWindowHeight} }; |
238 m_mainWnd = [[NSWindow alloc] | 238 m_mainWnd = [[NSWindow alloc] |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 [m_editWnd setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; | 306 [m_editWnd setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; |
307 [m_editWnd setTarget:web_view]; | 307 [m_editWnd setTarget:web_view]; |
308 [m_editWnd setAction:@selector(takeURLStringValueFrom:)]; | 308 [m_editWnd setAction:@selector(takeURLStringValueFrom:)]; |
309 [[m_editWnd cell] setWraps:NO]; | 309 [[m_editWnd cell] setWraps:NO]; |
310 [[m_editWnd cell] setScrollable:YES]; | 310 [[m_editWnd cell] setScrollable:YES]; |
311 | 311 |
312 // show the window | 312 // show the window |
313 [m_mainWnd makeKeyAndOrderFront: nil]; | 313 [m_mainWnd makeKeyAndOrderFront: nil]; |
314 | 314 |
315 // Load our initial content. | 315 // Load our initial content. |
316 if (!startingURL.empty()) | 316 if (starting_url.is_valid()) |
317 LoadURL(startingURL.c_str()); | 317 LoadURL(starting_url); |
318 | 318 |
319 bool bIsSVGTest = startingURL.find(L"W3C-SVG-1.1") != std::wstring::npos; | 319 if (IsSVGTestURL(starting_url)) { |
320 | |
321 if (bIsSVGTest) { | |
322 SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); | 320 SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); |
323 } else { | 321 } else { |
324 SizeToDefault(); | 322 SizeToDefault(); |
325 } | 323 } |
326 | 324 |
327 return true; | 325 return true; |
328 } | 326 } |
329 | 327 |
330 void TestShell::TestFinished() { | 328 void TestShell::TestFinished() { |
331 if (!test_is_pending_) | 329 if (!test_is_pending_) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 // offscreen. | 527 // offscreen. |
530 [shell->m_mainWnd orderOut:nil]; | 528 [shell->m_mainWnd orderOut:nil]; |
531 shell->ResizeSubViews(); | 529 shell->ResizeSubViews(); |
532 | 530 |
533 if (strstr(params.test_url.c_str(), "loading/")) | 531 if (strstr(params.test_url.c_str(), "loading/")) |
534 shell->layout_test_controller()->SetShouldDumpFrameLoadCallbacks(true); | 532 shell->layout_test_controller()->SetShouldDumpFrameLoadCallbacks(true); |
535 | 533 |
536 shell->test_is_preparing_ = true; | 534 shell->test_is_preparing_ = true; |
537 | 535 |
538 shell->set_test_params(¶ms); | 536 shell->set_test_params(¶ms); |
539 std::wstring wstr = UTF8ToWide(params.test_url.c_str()); | 537 shell->LoadURL(GURL(params.test_url)); |
540 shell->LoadURL(wstr.c_str()); | |
541 | 538 |
542 shell->test_is_preparing_ = false; | 539 shell->test_is_preparing_ = false; |
543 shell->WaitTestFinished(); | 540 shell->WaitTestFinished(); |
544 shell->set_test_params(NULL); | 541 shell->set_test_params(NULL); |
545 | 542 |
546 return true; | 543 return true; |
547 } | 544 } |
548 | 545 |
549 void TestShell::LoadURLForFrame(const wchar_t* url, | 546 void TestShell::LoadURLForFrame(const GURL& url, |
550 const wchar_t* frame_name) { | 547 const std::wstring& frame_name) { |
551 if (!url) | 548 if (!url.is_valid()) |
552 return; | 549 return; |
553 | 550 |
554 std::string url8 = WideToUTF8(url); | 551 if (IsSVGTestURL(url)) { |
555 | |
556 bool bIsSVGTest = strstr(url8.c_str(), "W3C-SVG-1.1") > 0; | |
557 | |
558 if (bIsSVGTest) { | |
559 SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); | 552 SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); |
560 } else { | 553 } else { |
561 // only resize back to the default when running tests | 554 // only resize back to the default when running tests |
562 if (layout_test_mode()) | 555 if (layout_test_mode()) |
563 SizeToDefault(); | 556 SizeToDefault(); |
564 } | 557 } |
565 | 558 |
566 std::string urlString(url8); | 559 navigation_controller_->LoadEntry( |
567 struct stat stat_buf; | 560 new TestNavigationEntry(-1, url, std::wstring(), frame_name)); |
568 if (!urlString.empty() && stat(url8.c_str(), &stat_buf) == 0) { | |
569 urlString.insert(0, "file://"); | |
570 } | |
571 | |
572 std::wstring frame_string; | |
573 if (frame_name) | |
574 frame_string = frame_name; | |
575 | |
576 navigation_controller_->LoadEntry(new TestNavigationEntry( | |
577 -1, GURL(urlString), std::wstring(), frame_string)); | |
578 } | 561 } |
579 | 562 |
580 bool TestShell::PromptForSaveFile(const wchar_t* prompt_title, | 563 bool TestShell::PromptForSaveFile(const wchar_t* prompt_title, |
581 std::wstring* result) | 564 std::wstring* result) |
582 { | 565 { |
583 NSSavePanel* save_panel = [NSSavePanel savePanel]; | 566 NSSavePanel* save_panel = [NSSavePanel savePanel]; |
584 | 567 |
585 /* set up new attributes */ | 568 /* set up new attributes */ |
586 [save_panel setRequiredFileType:@"txt"]; | 569 [save_panel setRequiredFileType:@"txt"]; |
587 [save_panel setMessage: | 570 [save_panel setMessage: |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 return false; | 690 return false; |
708 } | 691 } |
709 | 692 |
710 void DidLoadPlugin(const std::string& filename) { | 693 void DidLoadPlugin(const std::string& filename) { |
711 } | 694 } |
712 | 695 |
713 void DidUnloadPlugin(const std::string& filename) { | 696 void DidUnloadPlugin(const std::string& filename) { |
714 } | 697 } |
715 | 698 |
716 } // namespace webkit_glue | 699 } // namespace webkit_glue |
OLD | NEW |