OLD | NEW |
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/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_piece.h" | 13 #include "base/string_piece.h" |
14 #include "base/test/test_support_android.h" | 14 #include "base/test/test_support_android.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "grit/webkit_resources.h" | 16 #include "grit/webkit_resources.h" |
17 #include "net/android/network_library.h" | 17 #include "net/android/network_library.h" |
18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
19 #include "webkit/support/test_webkit_platform_support.h" | 19 #include "webkit/support/test_webkit_platform_support.h" |
20 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 20 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // The place where the Android layout test script will put the required tools | 24 // The place where the Android layout test script will put the required tools |
25 // and resources. Must keep consistent with DEVICE_DRT_DIR in | 25 // and resources. Must keep consistent with DEVICE_DRT_DIR in |
26 // WebKit/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py. | 26 // WebKit/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py. |
27 // TODO(wangxianzhu): Allow running DRT on non-rooted device by putting | 27 const char kDumpRenderTreeDir[] = "/data/local/tmp/drt"; |
28 // the tools and resources into the apk or under /data/local/tmp. | |
29 const char kDumpRenderTreeDir[] = "/data/drt"; | |
30 | 28 |
31 } | 29 } |
32 | 30 |
33 namespace webkit_support { | 31 namespace webkit_support { |
34 | 32 |
35 void BeforeInitialize(bool unit_test_mode) { | 33 void BeforeInitialize(bool unit_test_mode) { |
36 base::InitAndroidTestPaths(); | 34 base::InitAndroidTestPaths(); |
37 | 35 |
| 36 // Place cache under kDumpRenderTreeDir to allow the NRWT script to clear it. |
| 37 FilePath path(kDumpRenderTreeDir); |
| 38 path = path.Append("cache"); |
| 39 PathService::Override(base::DIR_CACHE, path); |
| 40 |
38 // Set XML_CATALOG_FILES environment variable to blank to prevent libxml from | 41 // Set XML_CATALOG_FILES environment variable to blank to prevent libxml from |
39 // loading and complaining the non-exsistent /etc/xml/catalog file. | 42 // loading and complaining the non-exsistent /etc/xml/catalog file. |
40 setenv("XML_CATALOG_FILES", "", 0); | 43 setenv("XML_CATALOG_FILES", "", 0); |
41 | 44 |
42 // For now TestWebKitAPI and webkit_unit_tests are standalone executables | 45 // For now TestWebKitAPI and webkit_unit_tests are standalone executables |
43 // which don't have Java capabilities. Init Java for only DumpRenderTree. | 46 // which don't have Java capabilities. Init Java for only DumpRenderTree. |
44 if (!unit_test_mode) { | 47 if (!unit_test_mode) { |
45 JNIEnv* env = base::android::AttachCurrentThread(); | 48 JNIEnv* env = base::android::AttachCurrentThread(); |
46 net::android::RegisterNetworkLibrary(env); | 49 net::android::RegisterNetworkLibrary(env); |
47 } | 50 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (!success) | 108 if (!success) |
106 LOG(FATAL) << "Failed reading: " << path.value(); | 109 LOG(FATAL) << "Failed reading: " << path.value(); |
107 } | 110 } |
108 return resize_corner_data; | 111 return resize_corner_data; |
109 } | 112 } |
110 } | 113 } |
111 | 114 |
112 return ResourceBundle::GetSharedInstance().GetRawDataResource( | 115 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
113 resource_id, scale_factor); | 116 resource_id, scale_factor); |
114 } | 117 } |
OLD | NEW |