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

Side by Side Diff: sky/tools/tester/test_runner.cc

Issue 797063002: Make reftests work for sky. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address review comments Created 6 years 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 | « sky/tools/tester/test_runner.h ('k') | sky/tools/tester/tester.cc » ('j') | 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/tools/tester/test_runner.h" 5 #include "sky/tools/tester/test_runner.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "mojo/public/cpp/application/connect.h" 9 #include "mojo/public/cpp/application/connect.h"
10 #include "mojo/public/cpp/application/service_provider_impl.h" 10 #include "mojo/public/cpp/application/service_provider_impl.h"
11 #include "mojo/services/view_manager/public/cpp/view.h" 11 #include "mojo/services/view_manager/public/cpp/view.h"
12 12
13 namespace sky { 13 namespace sky {
14 namespace tester { 14 namespace tester {
15 15
16 TestRunnerClient::~TestRunnerClient() { 16 TestRunnerClient::~TestRunnerClient() {
17 } 17 }
18 18
19 TestRunner::TestRunner(TestRunnerClient* client, mojo::View* container, 19 TestRunner::TestRunner(TestRunnerClient* client, mojo::View* container,
20 const std::string& url) 20 const std::string& url, bool enable_pixel_dumping)
21 : test_harness_factory_(this), 21 : test_harness_factory_(this),
22 client_(client), 22 client_(client),
23 weak_ptr_factory_(this) { 23 weak_ptr_factory_(this),
24 enable_pixel_dumping_(enable_pixel_dumping) {
24 CHECK(client); 25 CHECK(client);
25 26
26 scoped_ptr<mojo::ServiceProviderImpl> exported_services( 27 scoped_ptr<mojo::ServiceProviderImpl> exported_services(
27 new mojo::ServiceProviderImpl()); 28 new mojo::ServiceProviderImpl());
28 exported_services->AddService(&test_harness_factory_); 29 exported_services->AddService(&test_harness_factory_);
29 30
30 container->Embed(url, exported_services.Pass()); 31 container->Embed(url, exported_services.Pass());
31 } 32 }
32 33
33 TestRunner::~TestRunner() { 34 TestRunner::~TestRunner() {
34 } 35 }
35 36
36 base::WeakPtr<TestRunner> TestRunner::GetWeakPtr() { 37 base::WeakPtr<TestRunner> TestRunner::GetWeakPtr() {
37 return weak_ptr_factory_.GetWeakPtr(); 38 return weak_ptr_factory_.GetWeakPtr();
38 } 39 }
39 40
40 void TestRunner::OnTestStart() { 41 void TestRunner::OnTestStart() {
41 std::cout << "#BEGIN\n"; 42 std::cout << "#BEGIN\n";
42 std::cout.flush(); 43 std::cout.flush();
43 } 44 }
44 45
45 void TestRunner::OnTestComplete(const std::string& test_result) { 46 void TestRunner::OnTestComplete(const std::string& test_result,
47 const mojo::Array<uint8_t>& pixels) {
46 std::cout << "Content-Type: text/plain\n"; 48 std::cout << "Content-Type: text/plain\n";
47 std::cout << test_result << "\n"; 49 std::cout << test_result << "\n";
48 std::cout << "#EOF\n"; 50 std::cout << "#EOF\n";
51
52 // TODO(ojan): Don't generate the pixels if enable_pixel_dumping_ is false.
53 if (enable_pixel_dumping_) {
54 // TODO(ojan): Add real hashes here once we want to do pixel tests.
55 std::cout << "\nActualHash: FAKEHASHSTUB\n";
56 std::cout << "Content-Type: image/png\n";
57 std::cout << "Content-Length: " << pixels.size() << "\n";
58 std::cout.write(
59 reinterpret_cast<const char*>(&pixels[0]), pixels.size());
60 }
61
49 std::cout << "#EOF\n"; 62 std::cout << "#EOF\n";
50 std::cout.flush(); 63 std::cout.flush();
51 std::cerr << "#EOF\n"; 64 std::cerr << "#EOF\n";
52 std::cerr.flush(); 65 std::cerr.flush();
53 66
54 client_->OnTestComplete(); 67 client_->OnTestComplete();
55 } 68 }
56 69
57 } // namespace tester 70 } // namespace tester
58 } // namespace sky 71 } // namespace sky
OLDNEW
« no previous file with comments | « sky/tools/tester/test_runner.h ('k') | sky/tools/tester/tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698