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 } | 169 } |
169 | 170 |
170 // Set auto-launch app. | 171 // Set auto-launch app. |
171 { | 172 { |
172 // Observer must be notified twice: for policy list update and for | 173 // Observer must be notified twice: for policy list update and for |
173 // auto-launch app update. | 174 // auto-launch app update. |
174 NotificationWaiter waiter(manager(), 2); | 175 NotificationWaiter waiter(manager(), 2); |
175 SetApps(init_apps, GenerateAccountId(app2.package_name())); | 176 SetApps(init_apps, GenerateAccountId(app2.package_name())); |
176 waiter.Wait(); | 177 waiter.Wait(); |
177 EXPECT_TRUE(waiter.was_notified()); | 178 EXPECT_TRUE(waiter.was_notified()); |
178 | 179 |
179 EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid()); | 180 EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid()); |
180 ASSERT_EQ(2u, manager()->GetAllApps().size()); | |
181 | 181 |
182 ArcKioskAppManager::ArcKioskApps apps = manager()->GetAllApps(); | 182 ArcKioskAppManager::Apps apps; |
183 ASSERT_EQ(app1, apps[0].app_info()); | 183 manager()->GetAllApps(&apps); |
184 ASSERT_EQ(app2, apps[1].app_info()); | 184 ASSERT_EQ(2u, apps.size()); |
185 ASSERT_EQ(app1.package_name(), apps[0].name()); | 185 ASSERT_EQ(app1.package_name(), apps[0]->app_id()); |
186 ASSERT_EQ(app2.display_name(), apps[1].name()); | 186 ASSERT_EQ(app2.package_name(), apps[1]->app_id()); |
| 187 ASSERT_EQ(app1.package_name(), apps[0]->name()); |
| 188 ASSERT_EQ(app2.display_name(), apps[1]->name()); |
187 EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid()); | 189 EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid()); |
188 ASSERT_EQ(apps[1].account_id(), manager()->GetAutoLaunchAccountId()); | 190 ASSERT_EQ(apps[1]->account_id(), manager()->GetAutoLaunchAccountId()); |
189 } | 191 } |
190 | 192 |
191 // Create a new list of apps, where there is no app2 (is auto launch now), | 193 // Create a new list of apps, where there is no app2 (is auto launch now), |
192 // and present a new app. | 194 // and present a new app. |
193 policy::ArcKioskAppBasicInfo app3("com.package.name3", "", "", ""); | 195 policy::ArcKioskAppBasicInfo app3("com.package.name3", "", "", ""); |
194 std::vector<policy::ArcKioskAppBasicInfo> new_apps{app1, app3}; | 196 std::vector<policy::ArcKioskAppBasicInfo> new_apps{app1, app3}; |
195 { | 197 { |
196 // Observer must be notified once: app list was updated. | 198 // Observer must be notified once: app list was updated. |
197 NotificationWaiter waiter(manager(), 1); | 199 NotificationWaiter waiter(manager(), 1); |
198 SetApps(new_apps, std::string()); | 200 SetApps(new_apps, std::string()); |
199 waiter.Wait(); | 201 waiter.Wait(); |
200 EXPECT_TRUE(waiter.was_notified()); | 202 EXPECT_TRUE(waiter.was_notified()); |
201 | 203 |
202 ArcKioskAppManager::ArcKioskApps apps = manager()->GetAllApps(); | 204 ArcKioskAppManager::Apps apps; |
| 205 manager()->GetAllApps(&apps); |
203 ASSERT_EQ(2u, apps.size()); | 206 ASSERT_EQ(2u, apps.size()); |
204 ASSERT_EQ(app1, apps[0].app_info()); | 207 ASSERT_EQ(app1.package_name(), apps[0]->app_id()); |
205 ASSERT_EQ(app3, apps[1].app_info()); | 208 ASSERT_EQ(app3.package_name(), apps[1]->app_id()); |
206 ASSERT_EQ(app1.package_name(), apps[0].name()); | 209 ASSERT_EQ(app1.package_name(), apps[0]->name()); |
207 ASSERT_EQ(app3.package_name(), apps[1].name()); | 210 ASSERT_EQ(app3.package_name(), apps[1]->name()); |
208 // Auto launch app must be reset. | 211 // Auto launch app must be reset. |
209 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); | 212 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); |
210 } | 213 } |
211 | 214 |
212 // Claen the apps. | 215 // Claen the apps. |
213 { | 216 { |
214 // Observer must be notified once: app list was updated. | 217 // Observer must be notified once: app list was updated. |
215 NotificationWaiter waiter(manager(), 1); | 218 NotificationWaiter waiter(manager(), 1); |
216 CleanApps(); | 219 CleanApps(); |
217 waiter.Wait(); | 220 waiter.Wait(); |
218 EXPECT_TRUE(waiter.was_notified()); | 221 EXPECT_TRUE(waiter.was_notified()); |
219 | 222 |
220 ASSERT_EQ(0u, manager()->GetAllApps().size()); | 223 ArcKioskAppManager::Apps apps; |
| 224 manager()->GetAllApps(&apps); |
| 225 ASSERT_EQ(0u, apps.size()); |
221 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); | 226 EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid()); |
222 } | 227 } |
223 } | 228 } |
224 | 229 |
225 } // namespace chromeos | 230 } // namespace chromeos |
OLD | NEW |