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