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> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/run_loop.h" |
15 #include "mojo/common/common_type_converters.h" | 16 #include "mojo/common/common_type_converters.h" |
16 | 17 |
17 namespace mojo { | 18 namespace mojo { |
18 | 19 |
19 template <> | 20 template <> |
20 struct TypeConverter<arc::AppInfoPtr, arc::AppInfo> { | 21 struct TypeConverter<arc::AppInfoPtr, arc::AppInfo> { |
21 static arc::AppInfoPtr Convert(const arc::AppInfo& app_info) { | 22 static arc::AppInfoPtr Convert(const arc::AppInfo& app_info) { |
22 return app_info.Clone(); | 23 return app_info.Clone(); |
23 } | 24 } |
24 }; | 25 }; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 mojo::Array<uint8_t>::From(*png_data_as_string)); | 103 mojo::Array<uint8_t>::From(*png_data_as_string)); |
103 | 104 |
104 return true; | 105 return true; |
105 } | 106 } |
106 | 107 |
107 void FakeAppInstance::WaitForIncomingMethodCall() { | 108 void FakeAppInstance::WaitForIncomingMethodCall() { |
108 binding_.WaitForIncomingMethodCall(); | 109 binding_.WaitForIncomingMethodCall(); |
109 } | 110 } |
110 | 111 |
111 void FakeAppInstance::WaitForOnAppInstanceReady() { | 112 void FakeAppInstance::WaitForOnAppInstanceReady() { |
112 WaitForIncomingMethodCall(); // Wait for Init(). | 113 // Several messages are sent back and forth when OnAppInstanceReady() is |
113 WaitForIncomingMethodCall(); // Wait for RefreshAppList(). | 114 // called. Normally, it would be preferred to use a single |
| 115 // WaitForIncomingMethodCall() to wait for each method individually, but |
| 116 // QueryVersion() does require processing on the I/O thread, so |
| 117 // RunUntilIdle() is required to correctly dispatch it. On slower machines |
| 118 // (and when running under Valgrind), the two thread hops needed to send and |
| 119 // dispatch each Mojo message might not be picked up by a single |
| 120 // RunUntilIdle(), so keep pumping the message loop until all expected |
| 121 // messages are. |
| 122 while (refresh_app_list_count_ != 1) { |
| 123 base::RunLoop().RunUntilIdle(); |
| 124 } |
114 } | 125 } |
115 | 126 |
116 } // namespace arc | 127 } // namespace arc |
OLD | NEW |