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

Side by Side Diff: sky/viewer/internals.cc

Issue 866653002: Don't try to GetPixelsForTesting if not testing (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/edk/js/threading.h" 10 #include "mojo/edk/js/threading.h"
11 #include "mojo/public/cpp/application/connect.h" 11 #include "mojo/public/cpp/application/connect.h"
12 #include "mojo/public/cpp/bindings/array.h" 12 #include "mojo/public/cpp/bindings/array.h"
13 #include "sky/engine/public/web/WebDocument.h" 13 #include "sky/engine/public/web/WebDocument.h"
14 #include "sky/engine/public/web/WebFrame.h" 14 #include "sky/engine/public/web/WebFrame.h"
15 #include "sky/engine/public/web/WebView.h" 15 #include "sky/engine/public/web/WebView.h"
16 #include "sky/viewer/document_view.h" 16 #include "sky/viewer/document_view.h"
17 #include "sky/viewer/runtime_flags.h"
17 #include "v8/include/v8.h" 18 #include "v8/include/v8.h"
18 #include <limits> 19 #include <limits>
19 20
20 namespace sky { 21 namespace sky {
21 22
22 gin::WrapperInfo Internals::kWrapperInfo = {gin::kEmbedderNativeGin}; 23 gin::WrapperInfo Internals::kWrapperInfo = {gin::kEmbedderNativeGin};
23 24
24 // static 25 // static
25 gin::Handle<Internals> Internals::Create( 26 gin::Handle<Internals> Internals::Create(
26 v8::Isolate* isolate, DocumentView* document_view) { 27 v8::Isolate* isolate, DocumentView* document_view) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 66 }
66 67
67 std::string Internals::ContentAsText() { 68 std::string Internals::ContentAsText() {
68 if (!document_view_) 69 if (!document_view_)
69 return std::string(); 70 return std::string();
70 return document_view_->web_view()->mainFrame()->contentAsText( 71 return document_view_->web_view()->mainFrame()->contentAsText(
71 1024*1024).utf8(); 72 1024*1024).utf8();
72 } 73 }
73 74
74 void Internals::NotifyTestComplete(const std::string& test_result) { 75 void Internals::NotifyTestComplete(const std::string& test_result) {
76 if (!RuntimeFlags::Get().testing())
77 return;
75 std::vector<unsigned char> pixels; 78 std::vector<unsigned char> pixels;
76 document_view_->GetPixelsForTesting(&pixels); 79 document_view_->GetPixelsForTesting(&pixels);
77 test_harness_->OnTestComplete(test_result, 80 test_harness_->OnTestComplete(test_result,
78 mojo::Array<uint8_t>::From(pixels)); 81 mojo::Array<uint8_t>::From(pixels));
79 } 82 }
80 83
81 mojo::Handle Internals::ConnectToEmbedderService( 84 mojo::Handle Internals::ConnectToEmbedderService(
82 const std::string& interface_name) { 85 const std::string& interface_name) {
83 if (!document_view_) 86 if (!document_view_)
84 return mojo::Handle(); 87 return mojo::Handle();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 127 }
125 128
126 void Internals::pauseAnimations(double pauseTime) { 129 void Internals::pauseAnimations(double pauseTime) {
127 if (pauseTime < 0) 130 if (pauseTime < 0)
128 return; 131 return;
129 132
130 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin g(pauseTime); 133 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin g(pauseTime);
131 } 134 }
132 135
133 } // namespace sky 136 } // namespace sky
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698