| 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 #include <sys/stat.h> | 7 #include <sys/stat.h> |
| 8 | 8 |
| 9 #include "webkit/tools/test_shell/test_shell.h" | 9 #include "webkit/tools/test_shell/test_shell.h" |
| 10 | 10 |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 658 |
| 659 /* display the NSSavePanel */ | 659 /* display the NSSavePanel */ |
| 660 if ([save_panel runModalForDirectory:NSHomeDirectory() file:@""] == | 660 if ([save_panel runModalForDirectory:NSHomeDirectory() file:@""] == |
| 661 NSOKButton) { | 661 NSOKButton) { |
| 662 result->assign(UTF8ToWide([[save_panel filename] UTF8String])); | 662 result->assign(UTF8ToWide([[save_panel filename] UTF8String])); |
| 663 return true; | 663 return true; |
| 664 } | 664 } |
| 665 return false; | 665 return false; |
| 666 } | 666 } |
| 667 | 667 |
| 668 static void WriteTextToFile(const std::string& data, | |
| 669 const std::string& file_path) | |
| 670 { | |
| 671 FILE* fp = fopen(file_path.c_str(), "w"); | |
| 672 if (!fp) | |
| 673 return; | |
| 674 fwrite(data.c_str(), sizeof(std::string::value_type), data.size(), fp); | |
| 675 fclose(fp); | |
| 676 } | |
| 677 | |
| 678 void TestShell::DumpDocumentText() | |
| 679 { | |
| 680 std::wstring file_path; | |
| 681 if (!PromptForSaveFile(L"Dump document text", &file_path)) | |
| 682 return; | |
| 683 | |
| 684 WriteTextToFile( | |
| 685 WideToUTF8(webkit_glue::DumpDocumentText(webView()->GetMainFrame())), | |
| 686 WideToUTF8(file_path)); | |
| 687 } | |
| 688 | |
| 689 void TestShell::DumpRenderTree() | |
| 690 { | |
| 691 std::wstring file_path; | |
| 692 if (!PromptForSaveFile(L"Dump render tree", &file_path)) | |
| 693 return; | |
| 694 | |
| 695 WriteTextToFile( | |
| 696 WideToUTF8(webkit_glue::DumpRenderer(webView()->GetMainFrame())), | |
| 697 WideToUTF8(file_path)); | |
| 698 } | |
| 699 | |
| 700 // static | 668 // static |
| 701 std::string TestShell::RewriteLocalUrl(const std::string& url) { | 669 std::string TestShell::RewriteLocalUrl(const std::string& url) { |
| 702 // Convert file:///tmp/LayoutTests urls to the actual location on disk. | 670 // Convert file:///tmp/LayoutTests urls to the actual location on disk. |
| 703 const char kPrefix[] = "file:///tmp/LayoutTests/"; | 671 const char kPrefix[] = "file:///tmp/LayoutTests/"; |
| 704 const int kPrefixLen = arraysize(kPrefix) - 1; | 672 const int kPrefixLen = arraysize(kPrefix) - 1; |
| 705 | 673 |
| 706 std::string new_url(url); | 674 std::string new_url(url); |
| 707 if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { | 675 if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { |
| 708 FilePath replace_path; | 676 FilePath replace_path; |
| 709 PathService::Get(base::DIR_EXE, &replace_path); | 677 PathService::Get(base::DIR_EXE, &replace_path); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 return false; | 722 return false; |
| 755 } | 723 } |
| 756 | 724 |
| 757 void DidLoadPlugin(const std::string& filename) { | 725 void DidLoadPlugin(const std::string& filename) { |
| 758 } | 726 } |
| 759 | 727 |
| 760 void DidUnloadPlugin(const std::string& filename) { | 728 void DidUnloadPlugin(const std::string& filename) { |
| 761 } | 729 } |
| 762 | 730 |
| 763 } // namespace webkit_glue | 731 } // namespace webkit_glue |
| OLD | NEW |