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

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

Issue 1235053003: Remove //sky/tools/tester (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 | « 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sky/tools/tester/test_runner.h"
6
7 #include <iostream>
8 #include "base/bind.h"
9 #include "mojo/public/cpp/application/connect.h"
10 #include "mojo/services/view_manager/public/cpp/view.h"
11
12 namespace sky {
13 namespace tester {
14
15 TestRunnerClient::~TestRunnerClient() {
16 }
17
18 TestRunner::TestRunner(TestRunnerClient* client,
19 mojo::View* container,
20 const std::string& url,
21 bool enable_pixel_dumping)
22 : client_(client),
23 enable_pixel_dumping_(enable_pixel_dumping),
24 weak_ptr_factory_(this) {
25 CHECK(client);
26
27 mojo::ServiceProviderPtr test_harness_provider;
28 test_harness_provider_impl_.AddService(this);
29 test_harness_provider_impl_.Bind(GetProxy(&test_harness_provider));
30
31 container->Embed(url, nullptr, test_harness_provider.Pass());
32 }
33
34 TestRunner::~TestRunner() {
35 }
36
37 base::WeakPtr<TestRunner> TestRunner::GetWeakPtr() {
38 return weak_ptr_factory_.GetWeakPtr();
39 }
40
41 void TestRunner::OnTestStart() {
42 std::cout << "#BEGIN\n";
43 std::cout.flush();
44 }
45
46 void TestRunner::OnTestComplete(const std::string& test_result,
47 const mojo::Array<uint8_t>& pixels) {
48 std::cout << "Content-Type: text/plain\n";
49 std::cout << test_result << "\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 CHECK(pixels.size()) << "Could not dump pixels. Did you call notifyTestCompl ete before the first paint?";
59 std::cout.write(
60 reinterpret_cast<const char*>(&pixels[0]), pixels.size());
61 }
62
63 std::cout << "#EOF\n";
64 std::cout.flush();
65 std::cerr << "#EOF\n";
66 std::cerr.flush();
67
68 client_->OnTestComplete();
69 }
70
71 void TestRunner::Create(mojo::ApplicationConnection* app,
72 mojo::InterfaceRequest<TestHarness> request) {
73 new TestHarnessImpl(this, request.Pass());
74 }
75
76 } // namespace tester
77 } // 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