OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/file_system/file_system_api.h" | 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) { | 359 TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) { |
360 // Non-component apps in auto-launch kiosk mode will be granted access | 360 // Non-component apps in auto-launch kiosk mode will be granted access |
361 // instantly without asking for user consent, but with a notification. | 361 // instantly without asking for user consent, but with a notification. |
362 { | 362 { |
363 scoped_refptr<Extension> auto_launch_kiosk_app( | 363 scoped_refptr<Extension> auto_launch_kiosk_app( |
364 test_util::BuildApp(ExtensionBuilder().Pass()) | 364 test_util::BuildApp(ExtensionBuilder().Pass()) |
365 .MergeManifest(DictionaryBuilder() | 365 .MergeManifest(DictionaryBuilder() |
366 .SetBoolean("kiosk_enabled", true) | 366 .SetBoolean("kiosk_enabled", true) |
367 .SetBoolean("kiosk_only", true)) | 367 .SetBoolean("kiosk_only", true)) |
368 .Build()); | 368 .Build()); |
369 user_manager_->AddKioskAppUser( | 369 user_manager_->AddKioskAppUser(auto_launch_kiosk_app->id()); |
370 AccountId::FromUserEmail(auto_launch_kiosk_app->id())); | 370 user_manager_->LoginUser(auto_launch_kiosk_app->id()); |
371 user_manager_->LoginUser( | |
372 AccountId::FromUserEmail(auto_launch_kiosk_app->id())); | |
373 | 371 |
374 TestingConsentProviderDelegate delegate; | 372 TestingConsentProviderDelegate delegate; |
375 delegate.SetIsAutoLaunched(true); | 373 delegate.SetIsAutoLaunched(true); |
376 ConsentProvider provider(&delegate); | 374 ConsentProvider provider(&delegate); |
377 EXPECT_TRUE(provider.IsGrantable(*auto_launch_kiosk_app)); | 375 EXPECT_TRUE(provider.IsGrantable(*auto_launch_kiosk_app)); |
378 | 376 |
379 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; | 377 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; |
380 provider.RequestConsent(*auto_launch_kiosk_app.get(), volume_, | 378 provider.RequestConsent(*auto_launch_kiosk_app.get(), volume_, |
381 true /* writable */, | 379 true /* writable */, |
382 base::Bind(&OnConsentReceived, &result)); | 380 base::Bind(&OnConsentReceived, &result)); |
383 base::RunLoop().RunUntilIdle(); | 381 base::RunLoop().RunUntilIdle(); |
384 | 382 |
385 EXPECT_EQ(0, delegate.show_dialog_counter()); | 383 EXPECT_EQ(0, delegate.show_dialog_counter()); |
386 EXPECT_EQ(1, delegate.show_notification_counter()); | 384 EXPECT_EQ(1, delegate.show_notification_counter()); |
387 EXPECT_EQ(ConsentProvider::CONSENT_GRANTED, result); | 385 EXPECT_EQ(ConsentProvider::CONSENT_GRANTED, result); |
388 } | 386 } |
389 | 387 |
390 // Non-component apps in manual-launch kiosk mode will be granted access after | 388 // Non-component apps in manual-launch kiosk mode will be granted access after |
391 // receiving approval from the user. | 389 // receiving approval from the user. |
392 scoped_refptr<Extension> manual_launch_kiosk_app( | 390 scoped_refptr<Extension> manual_launch_kiosk_app( |
393 test_util::BuildApp(ExtensionBuilder().Pass()) | 391 test_util::BuildApp(ExtensionBuilder().Pass()) |
394 .MergeManifest(DictionaryBuilder() | 392 .MergeManifest(DictionaryBuilder() |
395 .SetBoolean("kiosk_enabled", true) | 393 .SetBoolean("kiosk_enabled", true) |
396 .SetBoolean("kiosk_only", true)) | 394 .SetBoolean("kiosk_only", true)) |
397 .Build()); | 395 .Build()); |
398 user_manager_->KioskAppLoggedIn( | 396 user_manager_->KioskAppLoggedIn(manual_launch_kiosk_app->id()); |
399 AccountId::FromUserEmail(manual_launch_kiosk_app->id())); | |
400 { | 397 { |
401 TestingConsentProviderDelegate delegate; | 398 TestingConsentProviderDelegate delegate; |
402 delegate.SetDialogButton(ui::DIALOG_BUTTON_OK); | 399 delegate.SetDialogButton(ui::DIALOG_BUTTON_OK); |
403 ConsentProvider provider(&delegate); | 400 ConsentProvider provider(&delegate); |
404 EXPECT_TRUE(provider.IsGrantable(*manual_launch_kiosk_app)); | 401 EXPECT_TRUE(provider.IsGrantable(*manual_launch_kiosk_app)); |
405 | 402 |
406 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; | 403 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; |
407 provider.RequestConsent(*manual_launch_kiosk_app.get(), volume_, | 404 provider.RequestConsent(*manual_launch_kiosk_app.get(), volume_, |
408 true /* writable */, | 405 true /* writable */, |
409 base::Bind(&OnConsentReceived, &result)); | 406 base::Bind(&OnConsentReceived, &result)); |
(...skipping 19 matching lines...) Expand all Loading... |
429 base::RunLoop().RunUntilIdle(); | 426 base::RunLoop().RunUntilIdle(); |
430 | 427 |
431 EXPECT_EQ(1, delegate.show_dialog_counter()); | 428 EXPECT_EQ(1, delegate.show_dialog_counter()); |
432 EXPECT_EQ(0, delegate.show_notification_counter()); | 429 EXPECT_EQ(0, delegate.show_notification_counter()); |
433 EXPECT_EQ(ConsentProvider::CONSENT_REJECTED, result); | 430 EXPECT_EQ(ConsentProvider::CONSENT_REJECTED, result); |
434 } | 431 } |
435 } | 432 } |
436 #endif | 433 #endif |
437 | 434 |
438 } // namespace extensions | 435 } // namespace extensions |
OLD | NEW |