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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 std::string WaitForURL() { | 26 std::string WaitForURL() { |
27 std::string url; | 27 std::string url; |
28 std::cin >> url; | 28 std::cin >> url; |
29 return url; | 29 return url; |
30 } | 30 } |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 class SkyTester : public mojo::ApplicationDelegate, | 34 class SkyTester : public mojo::ApplicationDelegate, |
35 public mojo::ViewManagerDelegate, | 35 public mojo::ViewManagerDelegate, |
36 public mojo::WindowManagerDelegate, | 36 public window_manager::WindowManagerDelegate, |
37 public mojo::ViewObserver, | 37 public mojo::ViewObserver, |
38 public TestRunnerClient { | 38 public TestRunnerClient { |
39 public: | 39 public: |
40 SkyTester() | 40 SkyTester() |
41 : window_manager_app_(new mojo::WindowManagerApp(this, this)), | 41 : window_manager_app_(new window_manager::WindowManagerApp(this, this)), |
42 view_manager_(NULL), | 42 view_manager_(NULL), |
43 root_(NULL), | 43 root_(NULL), |
44 content_(NULL), | 44 content_(NULL), |
45 weak_ptr_factory_(this) {} | 45 weak_ptr_factory_(this) {} |
46 virtual ~SkyTester() {} | 46 virtual ~SkyTester() {} |
47 | 47 |
48 private: | 48 private: |
49 // Overridden from mojo::ApplicationDelegate: | 49 // Overridden from mojo::ApplicationDelegate: |
50 virtual void Initialize(mojo::ApplicationImpl* impl) override { | 50 virtual void Initialize(mojo::ApplicationImpl* impl) override { |
51 window_manager_app_->Initialize(impl); | 51 window_manager_app_->Initialize(impl); |
(...skipping 22 matching lines...) Expand all Loading... |
74 content_ = mojo::View::Create(view_manager_); | 74 content_ = mojo::View::Create(view_manager_); |
75 content_->SetBounds(root_->bounds()); | 75 content_->SetBounds(root_->bounds()); |
76 root_->AddChild(content_); | 76 root_->AddChild(content_); |
77 content_->SetVisible(true); | 77 content_->SetVisible(true); |
78 | 78 |
79 std::cout << "#READY\n"; | 79 std::cout << "#READY\n"; |
80 std::cout.flush(); | 80 std::cout.flush(); |
81 ScheduleRun(); | 81 ScheduleRun(); |
82 } | 82 } |
83 | 83 |
84 // Overridden from WindowManagerDelegate: | 84 // Overridden from window_manager::WindowManagerDelegate: |
85 virtual void Embed( | 85 virtual void Embed( |
86 const mojo::String& url, | 86 const mojo::String& url, |
87 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) override { | 87 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) override { |
88 } | 88 } |
89 | 89 |
90 virtual void OnViewManagerDisconnected( | 90 virtual void OnViewManagerDisconnected( |
91 mojo::ViewManager* view_manager) override { | 91 mojo::ViewManager* view_manager) override { |
92 view_manager_ = NULL; | 92 view_manager_ = NULL; |
93 root_ = NULL; | 93 root_ = NULL; |
94 } | 94 } |
(...skipping 23 matching lines...) Expand all Loading... |
118 test_runner_.reset(); | 118 test_runner_.reset(); |
119 if (url_from_args_.length()) | 119 if (url_from_args_.length()) |
120 exit(0); | 120 exit(0); |
121 ScheduleRun(); | 121 ScheduleRun(); |
122 } | 122 } |
123 | 123 |
124 void DispatchInputEvent(mojo::EventPtr event) override { | 124 void DispatchInputEvent(mojo::EventPtr event) override { |
125 window_manager_app_->DispatchInputEventToView(content_, event.Pass()); | 125 window_manager_app_->DispatchInputEventToView(content_, event.Pass()); |
126 } | 126 } |
127 | 127 |
128 scoped_ptr<mojo::WindowManagerApp> window_manager_app_; | 128 scoped_ptr<window_manager::WindowManagerApp> window_manager_app_; |
129 | 129 |
130 std::string url_from_args_; | 130 std::string url_from_args_; |
131 | 131 |
132 mojo::ViewManager* view_manager_; | 132 mojo::ViewManager* view_manager_; |
133 mojo::View* root_; | 133 mojo::View* root_; |
134 mojo::View* content_; | 134 mojo::View* content_; |
135 | 135 |
136 scoped_ptr<TestRunner> test_runner_; | 136 scoped_ptr<TestRunner> test_runner_; |
137 | 137 |
138 base::WeakPtrFactory<SkyTester> weak_ptr_factory_; | 138 base::WeakPtrFactory<SkyTester> weak_ptr_factory_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(SkyTester); | 140 DISALLOW_COPY_AND_ASSIGN(SkyTester); |
141 }; | 141 }; |
142 | 142 |
143 } // namespace tester | 143 } // namespace tester |
144 } // namespace examples | 144 } // namespace examples |
145 | 145 |
146 MojoResult MojoMain(MojoHandle shell_handle) { | 146 MojoResult MojoMain(MojoHandle shell_handle) { |
147 mojo::ApplicationRunnerChromium runner(new sky::tester::SkyTester); | 147 mojo::ApplicationRunnerChromium runner(new sky::tester::SkyTester); |
148 return runner.Run(shell_handle); | 148 return runner.Run(shell_handle); |
149 } | 149 } |
OLD | NEW |