OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sky/viewer/internals.h" | 5 #include "sky/viewer/internals.h" |
6 | 6 |
7 #include "mojo/edk/js/core.h" | 7 #include "mojo/edk/js/core.h" |
8 #include "mojo/edk/js/handle.h" | 8 #include "mojo/edk/js/handle.h" |
9 #include "mojo/edk/js/support.h" | 9 #include "mojo/edk/js/support.h" |
10 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
| 11 #include "mojo/public/cpp/bindings/array.h" |
11 #include "mojo/public/interfaces/application/shell.mojom.h" | 12 #include "mojo/public/interfaces/application/shell.mojom.h" |
12 #include "sky/engine/public/web/WebDocument.h" | 13 #include "sky/engine/public/web/WebDocument.h" |
13 #include "sky/engine/public/web/WebFrame.h" | 14 #include "sky/engine/public/web/WebFrame.h" |
14 #include "sky/engine/public/web/WebView.h" | 15 #include "sky/engine/public/web/WebView.h" |
15 #include "sky/viewer/document_view.h" | 16 #include "sky/viewer/document_view.h" |
16 #include "v8/include/v8.h" | 17 #include "v8/include/v8.h" |
17 #include <limits> | 18 #include <limits> |
18 | 19 |
19 namespace sky { | 20 namespace sky { |
20 | 21 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 59 } |
59 | 60 |
60 std::string Internals::ContentAsText() { | 61 std::string Internals::ContentAsText() { |
61 if (!document_view_) | 62 if (!document_view_) |
62 return std::string(); | 63 return std::string(); |
63 return document_view_->web_view()->mainFrame()->contentAsText( | 64 return document_view_->web_view()->mainFrame()->contentAsText( |
64 1024*1024).utf8(); | 65 1024*1024).utf8(); |
65 } | 66 } |
66 | 67 |
67 void Internals::NotifyTestComplete(const std::string& test_result) { | 68 void Internals::NotifyTestComplete(const std::string& test_result) { |
68 test_harness_->OnTestComplete(test_result); | 69 std::vector<unsigned char> pixels; |
| 70 document_view_->GetPixelsForTesting(&pixels); |
| 71 test_harness_->OnTestComplete(test_result, |
| 72 mojo::Array<uint8_t>::From(pixels)); |
69 } | 73 } |
70 | 74 |
71 mojo::Handle Internals::ConnectToService( | 75 mojo::Handle Internals::ConnectToService( |
72 const std::string& application_url, const std::string& interface_name) { | 76 const std::string& application_url, const std::string& interface_name) { |
73 if (!document_view_) | 77 if (!document_view_) |
74 return mojo::Handle(); | 78 return mojo::Handle(); |
75 | 79 |
76 mojo::ServiceProviderPtr service_provider; | 80 mojo::ServiceProviderPtr service_provider; |
77 document_view_->shell()->ConnectToApplication( | 81 document_view_->shell()->ConnectToApplication( |
78 application_url, mojo::GetProxy(&service_provider)); | 82 application_url, mojo::GetProxy(&service_provider)); |
79 | 83 |
80 mojo::MessagePipe pipe; | 84 mojo::MessagePipe pipe; |
81 service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); | 85 service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); |
82 return pipe.handle0.release(); | 86 return pipe.handle0.release(); |
83 } | 87 } |
84 | 88 |
85 void Internals::pauseAnimations(double pauseTime) { | 89 void Internals::pauseAnimations(double pauseTime) { |
86 if (pauseTime < 0) | 90 if (pauseTime < 0) |
87 return; | 91 return; |
88 | 92 |
89 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin
g(pauseTime); | 93 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin
g(pauseTime); |
90 } | 94 } |
91 | 95 |
92 } // namespace sky | 96 } // namespace sky |
OLD | NEW |