Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/browser/extensions/api/file_system/file_system_api_unittest.cc

Issue 1511103003: Use rvalue reference instead of ExtensionBuilder::pass() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit change(dana review) Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/permission_messages_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 EXPECT_TRUE(suggested_name.MaybeAsASCII().empty()); 309 EXPECT_TRUE(suggested_name.MaybeAsASCII().empty());
310 EXPECT_TRUE(suggested_extension.empty()); 310 EXPECT_TRUE(suggested_extension.empty());
311 #endif 311 #endif
312 } 312 }
313 313
314 #if defined(OS_CHROMEOS) 314 #if defined(OS_CHROMEOS)
315 TEST_F(FileSystemApiConsentProviderTest, ForNonKioskApps) { 315 TEST_F(FileSystemApiConsentProviderTest, ForNonKioskApps) {
316 // Component apps are not granted unless they are whitelisted. 316 // Component apps are not granted unless they are whitelisted.
317 { 317 {
318 scoped_refptr<Extension> component_extension( 318 scoped_refptr<Extension> component_extension(
319 test_util::BuildApp(ExtensionBuilder().SetLocation(Manifest::COMPONENT)) 319 test_util::BuildApp(
320 std::move(ExtensionBuilder().SetLocation(Manifest::COMPONENT)))
320 .Build()); 321 .Build());
321 TestingConsentProviderDelegate delegate; 322 TestingConsentProviderDelegate delegate;
322 ConsentProvider provider(&delegate); 323 ConsentProvider provider(&delegate);
323 EXPECT_FALSE(provider.IsGrantable(*component_extension)); 324 EXPECT_FALSE(provider.IsGrantable(*component_extension));
324 } 325 }
325 326
326 // Whitelitsed component apps are instantly granted access without asking 327 // Whitelitsed component apps are instantly granted access without asking
327 // user. 328 // user.
328 { 329 {
329 scoped_refptr<Extension> whitelisted_component_extension( 330 scoped_refptr<Extension> whitelisted_component_extension(
330 test_util::BuildApp(ExtensionBuilder().SetLocation(Manifest::COMPONENT)) 331 test_util::BuildApp(
332 std::move(ExtensionBuilder().SetLocation(Manifest::COMPONENT)))
331 .Build()); 333 .Build());
332 TestingConsentProviderDelegate delegate; 334 TestingConsentProviderDelegate delegate;
333 delegate.SetComponentWhitelist(whitelisted_component_extension->id()); 335 delegate.SetComponentWhitelist(whitelisted_component_extension->id());
334 ConsentProvider provider(&delegate); 336 ConsentProvider provider(&delegate);
335 EXPECT_TRUE(provider.IsGrantable(*whitelisted_component_extension)); 337 EXPECT_TRUE(provider.IsGrantable(*whitelisted_component_extension));
336 338
337 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; 339 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE;
338 provider.RequestConsent(*whitelisted_component_extension.get(), volume_, 340 provider.RequestConsent(*whitelisted_component_extension.get(), volume_,
339 true /* writable */, 341 true /* writable */,
340 base::Bind(&OnConsentReceived, &result)); 342 base::Bind(&OnConsentReceived, &result));
(...skipping 13 matching lines...) Expand all
354 ConsentProvider provider(&delegate); 356 ConsentProvider provider(&delegate);
355 EXPECT_FALSE(provider.IsGrantable(*non_component_extension)); 357 EXPECT_FALSE(provider.IsGrantable(*non_component_extension));
356 } 358 }
357 } 359 }
358 360
359 TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) { 361 TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) {
360 // Non-component apps in auto-launch kiosk mode will be granted access 362 // Non-component apps in auto-launch kiosk mode will be granted access
361 // instantly without asking for user consent, but with a notification. 363 // instantly without asking for user consent, but with a notification.
362 { 364 {
363 scoped_refptr<Extension> auto_launch_kiosk_app( 365 scoped_refptr<Extension> auto_launch_kiosk_app(
364 test_util::BuildApp(ExtensionBuilder().Pass()) 366 test_util::BuildApp(ExtensionBuilder())
365 .MergeManifest(DictionaryBuilder() 367 .MergeManifest(DictionaryBuilder()
366 .SetBoolean("kiosk_enabled", true) 368 .SetBoolean("kiosk_enabled", true)
367 .SetBoolean("kiosk_only", true)) 369 .SetBoolean("kiosk_only", true))
368 .Build()); 370 .Build());
369 user_manager_->AddKioskAppUser( 371 user_manager_->AddKioskAppUser(
370 AccountId::FromUserEmail(auto_launch_kiosk_app->id())); 372 AccountId::FromUserEmail(auto_launch_kiosk_app->id()));
371 user_manager_->LoginUser( 373 user_manager_->LoginUser(
372 AccountId::FromUserEmail(auto_launch_kiosk_app->id())); 374 AccountId::FromUserEmail(auto_launch_kiosk_app->id()));
373 375
374 TestingConsentProviderDelegate delegate; 376 TestingConsentProviderDelegate delegate;
375 delegate.SetIsAutoLaunched(true); 377 delegate.SetIsAutoLaunched(true);
376 ConsentProvider provider(&delegate); 378 ConsentProvider provider(&delegate);
377 EXPECT_TRUE(provider.IsGrantable(*auto_launch_kiosk_app)); 379 EXPECT_TRUE(provider.IsGrantable(*auto_launch_kiosk_app));
378 380
379 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; 381 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE;
380 provider.RequestConsent(*auto_launch_kiosk_app.get(), volume_, 382 provider.RequestConsent(*auto_launch_kiosk_app.get(), volume_,
381 true /* writable */, 383 true /* writable */,
382 base::Bind(&OnConsentReceived, &result)); 384 base::Bind(&OnConsentReceived, &result));
383 base::RunLoop().RunUntilIdle(); 385 base::RunLoop().RunUntilIdle();
384 386
385 EXPECT_EQ(0, delegate.show_dialog_counter()); 387 EXPECT_EQ(0, delegate.show_dialog_counter());
386 EXPECT_EQ(1, delegate.show_notification_counter()); 388 EXPECT_EQ(1, delegate.show_notification_counter());
387 EXPECT_EQ(ConsentProvider::CONSENT_GRANTED, result); 389 EXPECT_EQ(ConsentProvider::CONSENT_GRANTED, result);
388 } 390 }
389 391
390 // Non-component apps in manual-launch kiosk mode will be granted access after 392 // Non-component apps in manual-launch kiosk mode will be granted access after
391 // receiving approval from the user. 393 // receiving approval from the user.
392 scoped_refptr<Extension> manual_launch_kiosk_app( 394 scoped_refptr<Extension> manual_launch_kiosk_app(
393 test_util::BuildApp(ExtensionBuilder().Pass()) 395 test_util::BuildApp(ExtensionBuilder())
394 .MergeManifest(DictionaryBuilder() 396 .MergeManifest(DictionaryBuilder()
395 .SetBoolean("kiosk_enabled", true) 397 .SetBoolean("kiosk_enabled", true)
396 .SetBoolean("kiosk_only", true)) 398 .SetBoolean("kiosk_only", true))
397 .Build()); 399 .Build());
398 user_manager_->KioskAppLoggedIn( 400 user_manager_->KioskAppLoggedIn(
399 AccountId::FromUserEmail(manual_launch_kiosk_app->id())); 401 AccountId::FromUserEmail(manual_launch_kiosk_app->id()));
400 { 402 {
401 TestingConsentProviderDelegate delegate; 403 TestingConsentProviderDelegate delegate;
402 delegate.SetDialogButton(ui::DIALOG_BUTTON_OK); 404 delegate.SetDialogButton(ui::DIALOG_BUTTON_OK);
403 ConsentProvider provider(&delegate); 405 ConsentProvider provider(&delegate);
(...skipping 25 matching lines...) Expand all
429 base::RunLoop().RunUntilIdle(); 431 base::RunLoop().RunUntilIdle();
430 432
431 EXPECT_EQ(1, delegate.show_dialog_counter()); 433 EXPECT_EQ(1, delegate.show_dialog_counter());
432 EXPECT_EQ(0, delegate.show_notification_counter()); 434 EXPECT_EQ(0, delegate.show_notification_counter());
433 EXPECT_EQ(ConsentProvider::CONSENT_REJECTED, result); 435 EXPECT_EQ(ConsentProvider::CONSENT_REJECTED, result);
434 } 436 }
435 } 437 }
436 #endif 438 #endif
437 439
438 } // namespace extensions 440 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/permission_messages_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698