OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/arc/test/fake_app_instance.h" | 5 #include "components/arc/test/fake_app_instance.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 .AppendASCII(icon_file_name); | 100 .AppendASCII(icon_file_name); |
101 CHECK(base::PathExists(icon_file_path)); | 101 CHECK(base::PathExists(icon_file_path)); |
102 CHECK(base::ReadFileToString(icon_file_path, png_data_as_string)); | 102 CHECK(base::ReadFileToString(icon_file_path, png_data_as_string)); |
103 | 103 |
104 app_host_->OnAppIcon(app.package_name, app.activity, scale_factor, | 104 app_host_->OnAppIcon(app.package_name, app.activity, scale_factor, |
105 mojo::Array<uint8_t>::From(*png_data_as_string)); | 105 mojo::Array<uint8_t>::From(*png_data_as_string)); |
106 | 106 |
107 return true; | 107 return true; |
108 } | 108 } |
109 | 109 |
| 110 void FakeAppInstance::SetTaskInfo(int32_t task_id, |
| 111 const std::string& package_name, |
| 112 const std::string& activity) { |
| 113 task_id_to_info_[task_id].reset(new Request(package_name, activity)); |
| 114 } |
| 115 |
110 void FakeAppInstance::WaitForIncomingMethodCall() { | 116 void FakeAppInstance::WaitForIncomingMethodCall() { |
111 binding_.WaitForIncomingMethodCall(); | 117 binding_.WaitForIncomingMethodCall(); |
112 } | 118 } |
113 | 119 |
114 void FakeAppInstance::WaitForOnAppInstanceReady() { | 120 void FakeAppInstance::WaitForOnAppInstanceReady() { |
115 // Several messages are sent back and forth when OnAppInstanceReady() is | 121 // Several messages are sent back and forth when OnAppInstanceReady() is |
116 // called. Normally, it would be preferred to use a single | 122 // called. Normally, it would be preferred to use a single |
117 // WaitForIncomingMethodCall() to wait for each method individually, but | 123 // WaitForIncomingMethodCall() to wait for each method individually, but |
118 // QueryVersion() does require processing on the I/O thread, so | 124 // QueryVersion() does require processing on the I/O thread, so |
119 // RunUntilIdle() is required to correctly dispatch it. On slower machines | 125 // RunUntilIdle() is required to correctly dispatch it. On slower machines |
120 // (and when running under Valgrind), the two thread hops needed to send and | 126 // (and when running under Valgrind), the two thread hops needed to send and |
121 // dispatch each Mojo message might not be picked up by a single | 127 // dispatch each Mojo message might not be picked up by a single |
122 // RunUntilIdle(), so keep pumping the message loop until all expected | 128 // RunUntilIdle(), so keep pumping the message loop until all expected |
123 // messages are. | 129 // messages are. |
124 while (refresh_app_list_count_ != 1) { | 130 while (refresh_app_list_count_ != 1) { |
125 base::RunLoop().RunUntilIdle(); | 131 base::RunLoop().RunUntilIdle(); |
126 } | 132 } |
127 } | 133 } |
128 | 134 |
129 void FakeAppInstance::CanHandleResolution(const mojo::String& package_name, | 135 void FakeAppInstance::CanHandleResolution(const mojo::String& package_name, |
130 const mojo::String& activity, | 136 const mojo::String& activity, |
131 ScreenRectPtr dimension, | 137 ScreenRectPtr dimension, |
132 const CanHandleResolutionCallback& callback) { | 138 const CanHandleResolutionCallback& callback) { |
133 callback.Run(true); | 139 callback.Run(true); |
134 } | 140 } |
135 | 141 |
136 void FakeAppInstance::UninstallPackage(const mojo::String& package_name) { | 142 void FakeAppInstance::UninstallPackage(const mojo::String& package_name) { |
137 } | 143 } |
138 | 144 |
| 145 void FakeAppInstance::GetTaskInfo(int32_t task_id, |
| 146 const GetTaskInfoCallback& callback) { |
| 147 TaskIdToInfo::const_iterator it = task_id_to_info_.find(task_id); |
| 148 if (it != task_id_to_info_.end()) |
| 149 callback.Run(it->second->package_name(), it->second->activity()); |
| 150 else |
| 151 callback.Run(mojo::String(), mojo::String()); |
| 152 } |
| 153 |
139 } // namespace arc | 154 } // namespace arc |
OLD | NEW |