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

Side by Side Diff: webkit/support/platform_support_android.cc

Issue 10408091: Chromium support of running DumpRenderTree as an apk on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed an intentation Created 8 years, 6 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 "webkit/support/platform_support.h" 5 #include "webkit/support/platform_support.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/string_piece.h" 12 #include "base/string_piece.h"
13 #include "base/test/test_stub_android.h" 13 #include "base/test/test_support_android.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "grit/webkit_resources.h" 15 #include "grit/webkit_resources.h"
16 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
17 #include "webkit/support/test_webkit_platform_support.h" 17 #include "webkit/support/test_webkit_platform_support.h"
18 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 18 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
19 19
20 namespace {
21
22 // The place where the Android layout test script will put the required tools
23 // and resources. Must keep consistent with DEVICE_DRT_DIR in
24 // WebKit/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py.
25 // TODO(wangxianzhu): Allow running DRT on non-rooted device by putting
26 // the tools and resources into the apk or under /data/local/tmp.
27 const char kDumpRenderTreeDir[] = "/data/drt";
28
29 }
30
20 namespace webkit_support { 31 namespace webkit_support {
21 32
22 void BeforeInitialize(bool unit_test_mode) { 33 void BeforeInitialize(bool unit_test_mode) {
23 InitAndroidOSPathStub(); 34 InitAndroidTestPaths();
35
24 // Set XML_CATALOG_FILES environment variable to blank to prevent libxml from 36 // Set XML_CATALOG_FILES environment variable to blank to prevent libxml from
25 // loading and complaining the non-exsistent /etc/xml/catalog file. 37 // loading and complaining the non-exsistent /etc/xml/catalog file.
26 setenv("XML_CATALOG_FILES", "", 0); 38 setenv("XML_CATALOG_FILES", "", 0);
27 } 39 }
28 40
29 void AfterInitialize(bool unit_test_mode) { 41 void AfterInitialize(bool unit_test_mode) {
30 if (unit_test_mode) 42 if (unit_test_mode)
31 return; // We don't have a resource pack when running the unit-tests. 43 return; // We don't have a resource pack when running the unit-tests.
32 44
33 FilePath data_path; 45 FilePath data_path(kDumpRenderTreeDir);
34 PathService::Get(base::DIR_EXE, &data_path);
35 data_path = data_path.Append("DumpRenderTree.pak"); 46 data_path = data_path.Append("DumpRenderTree.pak");
36 ResourceBundle::InitSharedInstanceWithPakFile(data_path); 47 ResourceBundle::InitSharedInstanceWithPakFile(data_path);
37 48
38 // We enable file-over-http to bridge the file protocol to http protocol 49 // We enable file-over-http to bridge the file protocol to http protocol
39 // in here, which can 50 // in here, which can
40 // (1) run the layout tests on android target device, but never need to 51 // (1) run the layout tests on android target device, but never need to
41 // push the test files and corresponding resources to device, which saves 52 // push the test files and corresponding resources to device, which saves
42 // huge running time. 53 // huge running time.
43 // (2) still run non-http layout (tests not under LayoutTests/http) tests 54 // (2) still run non-http layout (tests not under LayoutTests/http) tests
44 // via file protocol without breaking test environment / convention of webkit 55 // via file protocol without breaking test environment / convention of webkit
(...skipping 12 matching lines...) Expand all
57 68
58 } // namespace webkit_support 69 } // namespace webkit_support
59 70
60 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { 71 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) {
61 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); 72 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
62 } 73 }
63 74
64 base::StringPiece TestWebKitPlatformSupport::GetDataResource( 75 base::StringPiece TestWebKitPlatformSupport::GetDataResource(
65 int resource_id, 76 int resource_id,
66 ui::ScaleFactor scale_factor) { 77 ui::ScaleFactor scale_factor) {
67 FilePath resources_path; 78 FilePath resources_path(kDumpRenderTreeDir);
68 PathService::Get(base::DIR_EXE, &resources_path);
69 resources_path = resources_path.Append("DumpRenderTree_resources"); 79 resources_path = resources_path.Append("DumpRenderTree_resources");
70 switch (resource_id) { 80 switch (resource_id) {
71 case IDR_BROKENIMAGE: { 81 case IDR_BROKENIMAGE: {
72 static std::string broken_image_data; 82 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ());
73 if (broken_image_data.empty()) { 83 if (broken_image_data.empty()) {
74 FilePath path = resources_path.Append("missingImage.gif"); 84 FilePath path = resources_path.Append("missingImage.gif");
75 bool success = file_util::ReadFileToString(path, &broken_image_data); 85 bool success = file_util::ReadFileToString(path, &broken_image_data);
76 if (!success) 86 if (!success)
77 LOG(FATAL) << "Failed reading: " << path.value(); 87 LOG(FATAL) << "Failed reading: " << path.value();
78 } 88 }
79 return broken_image_data; 89 return broken_image_data;
80 } 90 }
81 case IDR_TEXTAREA_RESIZER: { 91 case IDR_TEXTAREA_RESIZER: {
82 static std::string resize_corner_data; 92 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ());
83 if (resize_corner_data.empty()) { 93 if (resize_corner_data.empty()) {
84 FilePath path = resources_path.Append("textAreaResizeCorner.png"); 94 FilePath path = resources_path.Append("textAreaResizeCorner.png");
85 bool success = file_util::ReadFileToString(path, &resize_corner_data); 95 bool success = file_util::ReadFileToString(path, &resize_corner_data);
86 if (!success) 96 if (!success)
87 LOG(FATAL) << "Failed reading: " << path.value(); 97 LOG(FATAL) << "Failed reading: " << path.value();
88 } 98 }
89 return resize_corner_data; 99 return resize_corner_data;
90 } 100 }
91 } 101 }
92 102
93 return ResourceBundle::GetSharedInstance().GetRawDataResource( 103 return ResourceBundle::GetSharedInstance().GetRawDataResource(
94 resource_id, scale_factor); 104 resource_id, scale_factor);
95 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698