OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 std::vector<policy::ArcKioskAppBasicInfo> init_apps{app1, app2}; | 151 std::vector<policy::ArcKioskAppBasicInfo> init_apps{app1, app2}; |
152 | 152 |
153 // Set initial list of apps. | 153 // Set initial list of apps. |
154 { | 154 { |
155 // Observer must be notified once: app list was updated. | 155 // Observer must be notified once: app list was updated. |
156 NotificationWaiter waiter(manager(), 1); | 156 NotificationWaiter waiter(manager(), 1); |
157 SetApps(init_apps, std::string()); | 157 SetApps(init_apps, std::string()); |
158 waiter.Wait(); | 158 waiter.Wait(); |
159 EXPECT_TRUE(waiter.was_notified()); | 159 EXPECT_TRUE(waiter.was_notified()); |
160 | 160 |
161 ArcKioskAppManager::ArcKioskApps apps = manager()->GetAllApps(); | 161 ArcKioskAppManager::Apps apps; |
| 162 manager()->GetAllApps(&apps); |
162 ASSERT_EQ(2u, apps.size()); | 163 ASSERT_EQ(2u, apps.size()); |
163 ASSERT_EQ(app1, apps[0].app_info()); | 164 ASSERT_EQ(app1.package_name(), apps[0]->app_id()); |
164 ASSERT_EQ(app2, apps[1].app_info()); | 165 ASSERT_EQ(app2.package_name(), apps[1]->app_id()); |
165 ASSERT_EQ(app1.package_name(), apps[0].name()); | 166 ASSERT_EQ(app1.package_name(), apps[0]->name()); |
166 ASSERT_EQ(app2.display_name(), apps[1].name()); | 167 ASSERT_EQ(app2.display_name(), apps[1]->name()); |
167 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); | 168 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); |
168 EXPECT_FALSE(manager()->current_app_was_auto_launched_with_zero_delay()); | 169 EXPECT_FALSE(manager()->current_app_was_auto_launched_with_zero_delay()); |
169 } | 170 } |
170 | 171 |
171 // Set auto-launch app. | 172 // Set auto-launch app. |
172 { | 173 { |
173 // Observer must be notified twice: for policy list update and for | 174 // Observer must be notified twice: for policy list update and for |
174 // auto-launch app update. | 175 // auto-launch app update. |
175 NotificationWaiter waiter(manager(), 2); | 176 NotificationWaiter waiter(manager(), 2); |
176 SetApps(init_apps, GenerateAccountId(app2.package_name())); | 177 SetApps(init_apps, GenerateAccountId(app2.package_name())); |
177 waiter.Wait(); | 178 waiter.Wait(); |
178 EXPECT_TRUE(waiter.was_notified()); | 179 EXPECT_TRUE(waiter.was_notified()); |
179 | 180 |
180 EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid()); | 181 EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid()); |
181 ASSERT_EQ(2u, manager()->GetAllApps().size()); | |
182 | 182 |
183 ArcKioskAppManager::ArcKioskApps apps = manager()->GetAllApps(); | 183 ArcKioskAppManager::Apps apps; |
184 ASSERT_EQ(app1, apps[0].app_info()); | 184 manager()->GetAllApps(&apps); |
185 ASSERT_EQ(app2, apps[1].app_info()); | 185 ASSERT_EQ(2u, apps.size()); |
186 ASSERT_EQ(app1.package_name(), apps[0].name()); | 186 ASSERT_EQ(app1.package_name(), apps[0]->app_id()); |
187 ASSERT_EQ(app2.display_name(), apps[1].name()); | 187 ASSERT_EQ(app2.package_name(), apps[1]->app_id()); |
| 188 ASSERT_EQ(app1.package_name(), apps[0]->name()); |
| 189 ASSERT_EQ(app2.display_name(), apps[1]->name()); |
188 EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid()); | 190 EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid()); |
189 ASSERT_EQ(apps[1].account_id(), manager()->GetAutoLaunchAccountId()); | 191 ASSERT_EQ(apps[1]->account_id(), manager()->GetAutoLaunchAccountId()); |
190 EXPECT_TRUE(manager()->current_app_was_auto_launched_with_zero_delay()); | 192 EXPECT_TRUE(manager()->current_app_was_auto_launched_with_zero_delay()); |
191 } | 193 } |
192 | 194 |
193 // Create a new list of apps, where there is no app2 (is auto launch now), | 195 // Create a new list of apps, where there is no app2 (is auto launch now), |
194 // and present a new app. | 196 // and present a new app. |
195 policy::ArcKioskAppBasicInfo app3("com.package.name3", "", "", ""); | 197 policy::ArcKioskAppBasicInfo app3("com.package.name3", "", "", ""); |
196 std::vector<policy::ArcKioskAppBasicInfo> new_apps{app1, app3}; | 198 std::vector<policy::ArcKioskAppBasicInfo> new_apps{app1, app3}; |
197 { | 199 { |
198 // Observer must be notified once: app list was updated. | 200 // Observer must be notified once: app list was updated. |
199 NotificationWaiter waiter(manager(), 1); | 201 NotificationWaiter waiter(manager(), 1); |
200 SetApps(new_apps, std::string()); | 202 SetApps(new_apps, std::string()); |
201 waiter.Wait(); | 203 waiter.Wait(); |
202 EXPECT_TRUE(waiter.was_notified()); | 204 EXPECT_TRUE(waiter.was_notified()); |
203 | 205 |
204 ArcKioskAppManager::ArcKioskApps apps = manager()->GetAllApps(); | 206 ArcKioskAppManager::Apps apps; |
| 207 manager()->GetAllApps(&apps); |
205 ASSERT_EQ(2u, apps.size()); | 208 ASSERT_EQ(2u, apps.size()); |
206 ASSERT_EQ(app1, apps[0].app_info()); | 209 ASSERT_EQ(app1.package_name(), apps[0]->app_id()); |
207 ASSERT_EQ(app3, apps[1].app_info()); | 210 ASSERT_EQ(app3.package_name(), apps[1]->app_id()); |
208 ASSERT_EQ(app1.package_name(), apps[0].name()); | 211 ASSERT_EQ(app1.package_name(), apps[0]->name()); |
209 ASSERT_EQ(app3.package_name(), apps[1].name()); | 212 ASSERT_EQ(app3.package_name(), apps[1]->name()); |
210 // Auto launch app must be reset. | 213 // Auto launch app must be reset. |
211 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); | 214 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); |
212 EXPECT_FALSE(manager()->current_app_was_auto_launched_with_zero_delay()); | 215 EXPECT_FALSE(manager()->current_app_was_auto_launched_with_zero_delay()); |
213 } | 216 } |
214 | 217 |
215 // Clean the apps. | 218 // Clean the apps. |
216 { | 219 { |
217 // Observer must be notified once: app list was updated. | 220 // Observer must be notified once: app list was updated. |
218 NotificationWaiter waiter(manager(), 1); | 221 NotificationWaiter waiter(manager(), 1); |
219 CleanApps(); | 222 CleanApps(); |
220 waiter.Wait(); | 223 waiter.Wait(); |
221 EXPECT_TRUE(waiter.was_notified()); | 224 EXPECT_TRUE(waiter.was_notified()); |
222 | 225 |
223 ASSERT_EQ(0u, manager()->GetAllApps().size()); | 226 ArcKioskAppManager::Apps apps; |
| 227 manager()->GetAllApps(&apps); |
| 228 ASSERT_EQ(0u, apps.size()); |
224 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); | 229 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); |
225 } | 230 } |
226 } | 231 } |
227 | 232 |
228 } // namespace chromeos | 233 } // namespace chromeos |
OLD | NEW |