Chromium Code Reviews| 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 <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 std::string WaitForURL(bool* enable_pixel_dumping, |
|
esprehn
2014/12/11 23:18:59
Maybe return a struct of results? Having so many o
ojan
2014/12/13 00:18:33
Done. I made it an out param.
| |
| 27 std::string url; | 27 std::string* expected_pixel_hash) { |
| 28 std::cin >> url; | 28 // A test name is formated like file:///path/to/test'--pixel-test'pixelhash |
| 29 return url; | 29 std::string test_name; |
| 30 std::cin >> test_name; | |
| 31 | |
| 32 std::string pixel_switch; | |
| 33 std::string::size_type separator_position = test_name.find('\''); | |
| 34 if (separator_position != std::string::npos) { | |
| 35 pixel_switch = test_name.substr(separator_position + 1); | |
| 36 test_name.erase(separator_position); | |
| 37 } | |
| 38 | |
| 39 std::string pixel_hash; | |
| 40 separator_position = pixel_switch.find('\''); | |
| 41 if (separator_position != std::string::npos) { | |
| 42 pixel_hash = pixel_switch.substr(separator_position + 1); | |
| 43 pixel_switch.erase(separator_position); | |
| 44 } | |
| 45 | |
| 46 if (enable_pixel_dumping) | |
| 47 *enable_pixel_dumping = pixel_switch == "--pixel-test"; | |
| 48 if (expected_pixel_hash) | |
| 49 *expected_pixel_hash = pixel_hash; | |
| 50 | |
| 51 return test_name; | |
| 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 Loading... | |
| 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 bool enable_pixel_dumping = false; |
| 137 std::string expected_pixel_hash; | |
| 138 | |
| 139 std::string url = url_from_args_.length() ? url_from_args_ : WaitForURL(&ena ble_pixel_dumping, &expected_pixel_hash); | |
| 140 test_runner_.reset(new TestRunner(this, content_, url, enable_pixel_dumping) ); | |
| 115 } | 141 } |
| 116 | 142 |
| 117 void OnTestComplete() override { | 143 void OnTestComplete() override { |
| 118 test_runner_.reset(); | 144 test_runner_.reset(); |
| 119 if (url_from_args_.length()) | 145 if (url_from_args_.length()) |
| 120 exit(0); | 146 exit(0); |
| 121 ScheduleRun(); | 147 ScheduleRun(); |
| 122 } | 148 } |
| 123 | 149 |
| 124 void DispatchInputEvent(mojo::EventPtr event) override { | 150 void DispatchInputEvent(mojo::EventPtr event) override { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 140 DISALLOW_COPY_AND_ASSIGN(SkyTester); | 166 DISALLOW_COPY_AND_ASSIGN(SkyTester); |
| 141 }; | 167 }; |
| 142 | 168 |
| 143 } // namespace tester | 169 } // namespace tester |
| 144 } // namespace examples | 170 } // namespace examples |
| 145 | 171 |
| 146 MojoResult MojoMain(MojoHandle shell_handle) { | 172 MojoResult MojoMain(MojoHandle shell_handle) { |
| 147 mojo::ApplicationRunnerChromium runner(new sky::tester::SkyTester); | 173 mojo::ApplicationRunnerChromium runner(new sky::tester::SkyTester); |
| 148 return runner.Run(shell_handle); | 174 return runner.Run(shell_handle); |
| 149 } | 175 } |
| OLD | NEW |