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

Side by Side Diff: sky/tools/tester/tester.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.cc ('k') | sky/tools/webkitpy/layout_tests/port/base.py » ('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 <iostream> 5 #include <iostream>
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "mojo/application/application_runner_chromium.h" 8 #include "mojo/application/application_runner_chromium.h"
9 #include "mojo/public/c/system/main.h" 9 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 10 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/application/application_impl.h" 11 #include "mojo/public/cpp/application/application_impl.h"
12 #include "mojo/public/cpp/application/connect.h" 12 #include "mojo/public/cpp/application/connect.h"
13 #include "mojo/public/cpp/application/service_provider_impl.h" 13 #include "mojo/public/cpp/application/service_provider_impl.h"
14 #include "mojo/services/input_events/public/interfaces/input_events.mojom.h" 14 #include "mojo/services/input_events/public/interfaces/input_events.mojom.h"
15 #include "mojo/services/view_manager/public/cpp/view_manager.h" 15 #include "mojo/services/view_manager/public/cpp/view_manager.h"
16 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h" 16 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
17 #include "mojo/services/view_manager/public/cpp/view_observer.h" 17 #include "mojo/services/view_manager/public/cpp/view_observer.h"
18 #include "services/window_manager/window_manager_app.h" 18 #include "services/window_manager/window_manager_app.h"
19 #include "services/window_manager/window_manager_delegate.h" 19 #include "services/window_manager/window_manager_delegate.h"
20 #include "sky/tools/tester/test_runner.h" 20 #include "sky/tools/tester/test_runner.h"
21 21
22 namespace sky { 22 namespace sky {
23 namespace tester { 23 namespace tester {
24 namespace { 24 namespace {
25 25
26 std::string WaitForURL() { 26 struct UrlData {
27 std::string url; 27 std::string url;
28 std::cin >> url; 28 std::string expected_pixel_hash;
29 return url; 29 bool enable_pixel_dumping = false;
30 };
31
32 void WaitForURL(UrlData& data) {
33 // A test name is formated like file:///path/to/test'--pixel-test'pixelhash
34 std::cin >> data.url;
35
36 std::string pixel_switch;
37 std::string::size_type separator_position = data.url.find('\'');
38 if (separator_position != std::string::npos) {
39 pixel_switch = data.url.substr(separator_position + 1);
40 data.url.erase(separator_position);
41 }
42
43 std::string pixel_hash;
44 separator_position = pixel_switch.find('\'');
45 if (separator_position != std::string::npos) {
46 pixel_hash = pixel_switch.substr(separator_position + 1);
47 pixel_switch.erase(separator_position);
48 }
49
50 data.enable_pixel_dumping = pixel_switch == "--pixel-test";
51 data.expected_pixel_hash = pixel_hash;
30 } 52 }
31 53
32 } // namespace 54 } // namespace
33 55
34 class SkyTester : public mojo::ApplicationDelegate, 56 class SkyTester : public mojo::ApplicationDelegate,
35 public mojo::ViewManagerDelegate, 57 public mojo::ViewManagerDelegate,
36 public window_manager::WindowManagerDelegate, 58 public window_manager::WindowManagerDelegate,
37 public mojo::ViewObserver, 59 public mojo::ViewObserver,
38 public TestRunnerClient { 60 public TestRunnerClient {
39 public: 61 public:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 content_->SetBounds(new_bounds); 125 content_->SetBounds(new_bounds);
104 } 126 }
105 127
106 void ScheduleRun() { 128 void ScheduleRun() {
107 base::MessageLoop::current()->PostTask(FROM_HERE, 129 base::MessageLoop::current()->PostTask(FROM_HERE,
108 base::Bind(&SkyTester::Run, weak_ptr_factory_.GetWeakPtr())); 130 base::Bind(&SkyTester::Run, weak_ptr_factory_.GetWeakPtr()));
109 } 131 }
110 132
111 void Run() { 133 void Run() {
112 DCHECK(!test_runner_); 134 DCHECK(!test_runner_);
113 std::string url = url_from_args_.length() ? url_from_args_ : WaitForURL(); 135
114 test_runner_.reset(new TestRunner(this, content_, url)); 136 UrlData data;
137 if (url_from_args_.length()) {
138 data.url = url_from_args_;
139 } else {
140 WaitForURL(data);
141 }
142
143 test_runner_.reset(new TestRunner(this, content_, data.url,
144 data.enable_pixel_dumping));
115 } 145 }
116 146
117 void OnTestComplete() override { 147 void OnTestComplete() override {
118 test_runner_.reset(); 148 test_runner_.reset();
119 if (url_from_args_.length()) 149 if (url_from_args_.length())
120 exit(0); 150 exit(0);
121 ScheduleRun(); 151 ScheduleRun();
122 } 152 }
123 153
124 void DispatchInputEvent(mojo::EventPtr event) override { 154 void DispatchInputEvent(mojo::EventPtr event) override {
(...skipping 15 matching lines...) Expand all
140 DISALLOW_COPY_AND_ASSIGN(SkyTester); 170 DISALLOW_COPY_AND_ASSIGN(SkyTester);
141 }; 171 };
142 172
143 } // namespace tester 173 } // namespace tester
144 } // namespace examples 174 } // namespace examples
145 175
146 MojoResult MojoMain(MojoHandle shell_handle) { 176 MojoResult MojoMain(MojoHandle shell_handle) {
147 mojo::ApplicationRunnerChromium runner(new sky::tester::SkyTester); 177 mojo::ApplicationRunnerChromium runner(new sky::tester::SkyTester);
148 return runner.Run(shell_handle); 178 return runner.Run(shell_handle);
149 } 179 }
OLDNEW
« no previous file with comments | « sky/tools/tester/test_runner.cc ('k') | sky/tools/webkitpy/layout_tests/port/base.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698