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 "content/shell/layout_test_controller_host.h" | 5 #include "content/shell/layout_test_controller_host.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "content/public/browser/render_view_host.h" | 8 #include "content/public/browser/render_view_host.h" |
9 #include "content/shell/shell_messages.h" | 9 #include "content/shell/shell_messages.h" |
10 #include "webkit/support/webkit_support_gfx.h" | 10 #include "webkit/support/webkit_support_gfx.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 printf("%s#EOF\n", dump.c_str()); | 109 printf("%s#EOF\n", dump.c_str()); |
110 fprintf(stderr, "#EOF\n"); | 110 fprintf(stderr, "#EOF\n"); |
111 | 111 |
112 if (dump_as_text_) | 112 if (dump_as_text_) |
113 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 113 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
114 } | 114 } |
115 | 115 |
116 void LayoutTestControllerHost::OnImageDump( | 116 void LayoutTestControllerHost::OnImageDump( |
117 const std::string& actual_pixel_hash, | 117 const std::string& actual_pixel_hash, |
118 const SkBitmap& image) { | 118 const SkBitmap& image) { |
119 #if !defined(OS_ANDROID) | |
120 // DumpRenderTree is not currently supported for Android. Also, on Android | |
121 // the required webkit_support methods are not defined, so this method just | |
122 // doesn't compile. | |
123 | |
124 SkAutoLockPixels image_lock(image); | 119 SkAutoLockPixels image_lock(image); |
125 | 120 |
126 printf("\nActualHash: %s\n", actual_pixel_hash.c_str()); | 121 printf("\nActualHash: %s\n", actual_pixel_hash.c_str()); |
127 if (!expected_pixel_hash_.empty()) | 122 if (!expected_pixel_hash_.empty()) |
128 printf("\nExpectedHash: %s\n", expected_pixel_hash_.c_str()); | 123 printf("\nExpectedHash: %s\n", expected_pixel_hash_.c_str()); |
129 | 124 |
130 // Only encode and dump the png if the hashes don't match. Encoding the | 125 // Only encode and dump the png if the hashes don't match. Encoding the |
131 // image is really expensive. | 126 // image is really expensive. |
132 if (actual_pixel_hash != expected_pixel_hash_) { | 127 if (actual_pixel_hash != expected_pixel_hash_) { |
133 std::vector<unsigned char> png; | 128 std::vector<unsigned char> png; |
134 | 129 |
135 // Only the expected PNGs for Mac have a valid alpha channel. | 130 // Only the expected PNGs for Mac have a valid alpha channel. |
136 #if defined(OS_MACOSX) | 131 #if defined(OS_MACOSX) |
137 bool discard_transparency = false; | 132 bool discard_transparency = false; |
138 #else | 133 #else |
139 bool discard_transparency = true; | 134 bool discard_transparency = true; |
140 #endif | 135 #endif |
141 | 136 |
142 if (webkit_support::EncodeBGRAPNGWithChecksum( | 137 bool success = false; |
143 reinterpret_cast<const unsigned char*>(image.getPixels()), | 138 #if defined(OS_ANDROID) |
144 image.width(), | 139 success = webkit_support::EncodeRGBAPNGWithChecksum( |
145 image.height(), | 140 reinterpret_cast<const unsigned char*>(image.getPixels()), |
146 static_cast<int>(image.rowBytes()), | 141 image.width(), |
147 discard_transparency, | 142 image.height(), |
148 actual_pixel_hash, | 143 static_cast<int>(image.rowBytes()), |
149 &png)) { | 144 discard_transparency, |
| 145 actual_pixel_hash, |
| 146 &png); |
| 147 #else |
| 148 success = webkit_support::EncodeBGRAPNGWithChecksum( |
| 149 reinterpret_cast<const unsigned char*>(image.getPixels()), |
| 150 image.width(), |
| 151 image.height(), |
| 152 static_cast<int>(image.rowBytes()), |
| 153 discard_transparency, |
| 154 actual_pixel_hash, |
| 155 &png); |
| 156 #endif |
| 157 if (success) { |
150 printf("Content-Type: image/png\n"); | 158 printf("Content-Type: image/png\n"); |
151 printf("Content-Length: %u\n", static_cast<unsigned>(png.size())); | 159 printf("Content-Length: %u\n", static_cast<unsigned>(png.size())); |
152 fwrite(&png[0], 1, png.size(), stdout); | 160 fwrite(&png[0], 1, png.size(), stdout); |
153 } | 161 } |
154 } | 162 } |
155 | 163 |
156 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 164 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
157 #endif | |
158 } | 165 } |
159 | 166 |
160 void LayoutTestControllerHost::OnNotifyDone() { | 167 void LayoutTestControllerHost::OnNotifyDone() { |
161 if (!wait_until_done_) | 168 if (!wait_until_done_) |
162 return; | 169 return; |
163 watchdog_.Cancel(); | 170 watchdog_.Cancel(); |
164 CaptureDump(); | 171 CaptureDump(); |
165 } | 172 } |
166 | 173 |
167 void LayoutTestControllerHost::OnDumpAsText() { | 174 void LayoutTestControllerHost::OnDumpAsText() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 return; | 207 return; |
201 printf("FAIL: NOT IMPLEMENTED: %s.%s\n", | 208 printf("FAIL: NOT IMPLEMENTED: %s.%s\n", |
202 object_name.c_str(), property_name.c_str()); | 209 object_name.c_str(), property_name.c_str()); |
203 fprintf(stderr, "FAIL: NOT IMPLEMENTED: %s.%s\n", | 210 fprintf(stderr, "FAIL: NOT IMPLEMENTED: %s.%s\n", |
204 object_name.c_str(), property_name.c_str()); | 211 object_name.c_str(), property_name.c_str()); |
205 watchdog_.Cancel(); | 212 watchdog_.Cancel(); |
206 CaptureDump(); | 213 CaptureDump(); |
207 } | 214 } |
208 | 215 |
209 } // namespace content | 216 } // namespace content |
OLD | NEW |