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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #include <sys/stat.h> | 6 #include <sys/stat.h> |
7 | 7 |
8 #include "webkit/tools/test_shell/test_shell.h" | 8 #include "webkit/tools/test_shell/test_shell.h" |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return; | 569 return; |
570 fwrite(data.c_str(), sizeof(std::string::value_type), data.size(), fp); | 570 fwrite(data.c_str(), sizeof(std::string::value_type), data.size(), fp); |
571 fclose(fp); | 571 fclose(fp); |
572 } | 572 } |
573 | 573 |
574 void TestShell::DumpDocumentText() | 574 void TestShell::DumpDocumentText() |
575 { | 575 { |
576 std::wstring file_path; | 576 std::wstring file_path; |
577 if (!PromptForSaveFile(L"Dump document text", &file_path)) | 577 if (!PromptForSaveFile(L"Dump document text", &file_path)) |
578 return; | 578 return; |
579 | 579 |
580 WriteTextToFile( | 580 WriteTextToFile( |
581 WideToUTF8(webkit_glue::DumpDocumentText(webView()->GetMainFrame())), | 581 WideToUTF8(webkit_glue::DumpDocumentText(webView()->GetMainFrame())), |
582 WideToUTF8(file_path)); | 582 WideToUTF8(file_path)); |
583 } | 583 } |
584 | 584 |
585 void TestShell::DumpRenderTree() | 585 void TestShell::DumpRenderTree() |
586 { | 586 { |
587 std::wstring file_path; | 587 std::wstring file_path; |
588 if (!PromptForSaveFile(L"Dump render tree", &file_path)) | 588 if (!PromptForSaveFile(L"Dump render tree", &file_path)) |
589 return; | 589 return; |
590 | 590 |
591 WriteTextToFile( | 591 WriteTextToFile( |
592 WideToUTF8(webkit_glue::DumpRenderer(webView()->GetMainFrame())), | 592 WideToUTF8(webkit_glue::DumpRenderer(webView()->GetMainFrame())), |
593 WideToUTF8(file_path)); | 593 WideToUTF8(file_path)); |
594 } | 594 } |
595 | 595 |
596 /* static */ | 596 // static |
597 std::string TestShell::RewriteLocalUrl(const std::string& url) { | 597 std::string TestShell::RewriteLocalUrl(const std::string& url) { |
598 // Convert file:///tmp/LayoutTests urls to the actual location on disk. | 598 // Convert file:///tmp/LayoutTests urls to the actual location on disk. |
599 const char kPrefix[] = "file:///tmp/LayoutTests/"; | 599 const char kPrefix[] = "file:///tmp/LayoutTests/"; |
600 const int kPrefixLen = arraysize(kPrefix) - 1; | 600 const int kPrefixLen = arraysize(kPrefix) - 1; |
601 | 601 |
602 std::string new_url(url); | 602 std::string new_url(url); |
603 if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { | 603 if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { |
604 std::wstring replace_url; | 604 FilePath replace_path; |
605 PathService::Get(base::DIR_EXE, &replace_url); | 605 PathService::Get(base::DIR_EXE, &replace_path); |
606 file_util::UpOneDirectory(&replace_url); | 606 replace_path = replace_path.DirName().DirName().Append( |
607 file_util::UpOneDirectory(&replace_url); | 607 "webkit/data/layout_tests/LayoutTests/"); |
608 file_util::AppendToPath(&replace_url, L"webkit"); | 608 new_url = std::string("file://") + replace_path.value() + |
609 file_util::AppendToPath(&replace_url, L"data"); | 609 url.substr(kPrefixLen); |
610 file_util::AppendToPath(&replace_url, L"layout_tests"); | |
611 file_util::AppendToPath(&replace_url, L"LayoutTests"); | |
612 replace_url.push_back(file_util::kPathSeparator); | |
613 std::string replace_url8 = WideToUTF8(replace_url); | |
614 new_url = std::string("file:///") + | |
615 replace_url8.append(url.substr(kPrefixLen)); | |
616 } | 610 } |
| 611 |
617 return new_url; | 612 return new_url; |
618 } | 613 } |
619 | 614 |
620 // static | 615 // static |
621 void TestShell::ShowStartupDebuggingDialog() { | 616 void TestShell::ShowStartupDebuggingDialog() { |
622 // TODO(port): Show a modal dialog here with an attach to me message. | 617 // TODO(port): Show a modal dialog here with an attach to me message. |
623 } | 618 } |
624 | 619 |
625 //----------------------------------------------------------------------------- | 620 //----------------------------------------------------------------------------- |
626 | 621 |
627 namespace webkit_glue { | 622 namespace webkit_glue { |
628 | 623 |
629 std::wstring GetLocalizedString(int message_id) { | 624 std::wstring GetLocalizedString(int message_id) { |
630 NSString* idString = [NSString stringWithFormat:@"%d", message_id]; | 625 NSString* idString = [NSString stringWithFormat:@"%d", message_id]; |
631 NSString* localString = NSLocalizedString(idString, @""); | 626 NSString* localString = NSLocalizedString(idString, @""); |
632 | 627 |
633 return UTF8ToWide([localString UTF8String]); | 628 return UTF8ToWide([localString UTF8String]); |
634 } | 629 } |
635 | 630 |
636 NSCursor* LoadCursor(int cursor_id) { | 631 NSCursor* LoadCursor(int cursor_id) { |
637 // TODO(port): add some more options here | 632 // TODO(port): add some more options here |
638 return [NSCursor arrowCursor]; | 633 return [NSCursor arrowCursor]; |
639 } | 634 } |
640 | 635 |
641 bool GetInspectorHTMLPath(std::string* path) { | 636 bool GetInspectorHTMLPath(std::string* path) { |
642 NSString* resource_path = [[NSBundle mainBundle] resourcePath]; | 637 NSString* resource_path = [[NSBundle mainBundle] resourcePath]; |
(...skipping 19 matching lines...) Expand all Loading... |
662 return false; | 657 return false; |
663 } | 658 } |
664 | 659 |
665 void DidLoadPlugin(const std::string& filename) { | 660 void DidLoadPlugin(const std::string& filename) { |
666 } | 661 } |
667 | 662 |
668 void DidUnloadPlugin(const std::string& filename) { | 663 void DidUnloadPlugin(const std::string& filename) { |
669 } | 664 } |
670 | 665 |
671 } // namespace webkit_glue | 666 } // namespace webkit_glue |
OLD | NEW |