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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_tasks_unittest.cc

Issue 1739183003: Make extensions::DictionaryBuilder and extensions::ListValue unmovable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/file_manager/file_tasks.h" 5 #include "chrome/browser/chromeos/file_manager/file_tasks.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 445
446 // The basic logic is similar to a test case for FindDriveAppTasks above. 446 // The basic logic is similar to a test case for FindDriveAppTasks above.
447 TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) { 447 TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) {
448 // Random IDs generated by 448 // Random IDs generated by
449 // % ruby -le 'print (0...32).to_a.map{(?a + rand(16)).chr}.join' 449 // % ruby -le 'print (0...32).to_a.map{(?a + rand(16)).chr}.join'
450 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; 450 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
451 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; 451 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
452 452
453 // Foo.app can handle "text/plain" and "text/html". 453 // Foo.app can handle "text/plain" and "text/html".
454 extensions::ExtensionBuilder foo_app; 454 extensions::ExtensionBuilder foo_app;
455 foo_app.SetManifest(std::move( 455 foo_app.SetManifest(
456 extensions::DictionaryBuilder() 456 extensions::DictionaryBuilder()
457 .Set("name", "Foo") 457 .Set("name", "Foo")
458 .Set("version", "1.0.0") 458 .Set("version", "1.0.0")
459 .Set("manifest_version", 2) 459 .Set("manifest_version", 2)
460 .Set("app", 460 .Set("app", extensions::DictionaryBuilder()
461 std::move(extensions::DictionaryBuilder().Set( 461 .Set("background",
462 "background", 462 extensions::DictionaryBuilder()
463 std::move(extensions::DictionaryBuilder().Set( 463 .Set("scripts", extensions::ListBuilder()
464 "scripts", std::move(extensions::ListBuilder().Append( 464 .Append("background.js")
465 "background.js"))))))) 465 .Build())
466 .Set( 466 .Build())
467 "file_handlers", 467 .Build())
468 std::move(extensions::DictionaryBuilder().Set( 468 .Set("file_handlers",
469 "text", 469 extensions::DictionaryBuilder()
470 std::move(extensions::DictionaryBuilder() 470 .Set("text", extensions::DictionaryBuilder()
471 .Set("title", "Text") 471 .Set("title", "Text")
472 .Set("types", 472 .Set("types", extensions::ListBuilder()
473 std::move(extensions::ListBuilder() 473 .Append("text/plain")
474 .Append("text/plain") 474 .Append("text/html")
475 .Append("text/html"))))))))); 475 .Build())
476 .Build())
477 .Build())
478 .Build());
476 foo_app.SetID(kFooId); 479 foo_app.SetID(kFooId);
477 extension_service_->AddExtension(foo_app.Build().get()); 480 extension_service_->AddExtension(foo_app.Build().get());
478 481
479 // Bar.app can only handle "text/plain". 482 // Bar.app can only handle "text/plain".
480 extensions::ExtensionBuilder bar_app; 483 extensions::ExtensionBuilder bar_app;
481 bar_app.SetManifest(std::move( 484 bar_app.SetManifest(
482 extensions::DictionaryBuilder() 485 extensions::DictionaryBuilder()
483 .Set("name", "Bar") 486 .Set("name", "Bar")
484 .Set("version", "1.0.0") 487 .Set("version", "1.0.0")
485 .Set("manifest_version", 2) 488 .Set("manifest_version", 2)
486 .Set("app", 489 .Set("app", extensions::DictionaryBuilder()
487 std::move(extensions::DictionaryBuilder().Set( 490 .Set("background",
488 "background", 491 extensions::DictionaryBuilder()
489 std::move(extensions::DictionaryBuilder().Set( 492 .Set("scripts", extensions::ListBuilder()
490 "scripts", std::move(extensions::ListBuilder().Append( 493 .Append("background.js")
491 "background.js"))))))) 494 .Build())
492 .Set( 495 .Build())
493 "file_handlers", 496 .Build())
494 std::move(extensions::DictionaryBuilder().Set( 497 .Set("file_handlers",
495 "text", 498 extensions::DictionaryBuilder()
496 std::move(extensions::DictionaryBuilder() 499 .Set("text", extensions::DictionaryBuilder()
497 .Set("title", "Text") 500 .Set("title", "Text")
498 .Set("types", 501 .Set("types", extensions::ListBuilder()
499 std::move(extensions::ListBuilder().Append( 502 .Append("text/plain")
500 "text/plain"))))))))); 503 .Build())
504 .Build())
505 .Build())
506 .Build());
501 bar_app.SetID(kBarId); 507 bar_app.SetID(kBarId);
502 extension_service_->AddExtension(bar_app.Build().get()); 508 extension_service_->AddExtension(bar_app.Build().get());
503 509
504 // Find apps for a "text/plain" file. Foo.app and Bar.app should be found. 510 // Find apps for a "text/plain" file. Foo.app and Bar.app should be found.
505 std::vector<extensions::EntryInfo> entries; 511 std::vector<extensions::EntryInfo> entries;
506 entries.push_back( 512 entries.push_back(
507 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) 513 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_)
508 .AppendASCII("foo.txt"), 514 .AppendASCII("foo.txt"),
509 "text/plain", false)); 515 "text/plain", false));
510 516
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 554
549 // The basic logic is similar to a test case for FindDriveAppTasks above. 555 // The basic logic is similar to a test case for FindDriveAppTasks above.
550 TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) { 556 TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) {
551 // Copied from FindFileHandlerTasks test above. 557 // Copied from FindFileHandlerTasks test above.
552 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; 558 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
553 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; 559 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
554 560
555 // Foo.app can handle ".txt" and ".html". 561 // Foo.app can handle ".txt" and ".html".
556 // This one is an extension, and has "file_browser_handlers" 562 // This one is an extension, and has "file_browser_handlers"
557 extensions::ExtensionBuilder foo_app; 563 extensions::ExtensionBuilder foo_app;
558 foo_app.SetManifest(std::move( 564 foo_app.SetManifest(
559 extensions::DictionaryBuilder() 565 extensions::DictionaryBuilder()
560 .Set("name", "Foo") 566 .Set("name", "Foo")
561 .Set("version", "1.0.0") 567 .Set("version", "1.0.0")
562 .Set("manifest_version", 2) 568 .Set("manifest_version", 2)
563 .Set("permissions", std::move(extensions::ListBuilder().Append( 569 .Set("permissions",
564 "fileBrowserHandler"))) 570 extensions::ListBuilder().Append("fileBrowserHandler").Build())
565 .Set("file_browser_handlers", 571 .Set("file_browser_handlers",
566 std::move(extensions::ListBuilder().Append(std::move( 572 extensions::ListBuilder()
567 extensions::DictionaryBuilder() 573 .Append(
568 .Set("id", "open") 574 extensions::DictionaryBuilder()
569 .Set("default_title", "open") 575 .Set("id", "open")
570 .Set("file_filters", 576 .Set("default_title", "open")
571 std::move(extensions::ListBuilder() 577 .Set("file_filters", extensions::ListBuilder()
572 .Append("filesystem:*.txt") 578 .Append("filesystem:*.txt")
573 .Append("filesystem:*.html"))))))))); 579 .Append("filesystem:*.html")
580 .Build())
581 .Build())
582 .Build())
583 .Build());
574 foo_app.SetID(kFooId); 584 foo_app.SetID(kFooId);
575 extension_service_->AddExtension(foo_app.Build().get()); 585 extension_service_->AddExtension(foo_app.Build().get());
576 586
577 // Bar.app can only handle ".txt". 587 // Bar.app can only handle ".txt".
578 extensions::ExtensionBuilder bar_app; 588 extensions::ExtensionBuilder bar_app;
579 bar_app.SetManifest(std::move( 589 bar_app.SetManifest(
580 extensions::DictionaryBuilder() 590 extensions::DictionaryBuilder()
581 .Set("name", "Bar") 591 .Set("name", "Bar")
582 .Set("version", "1.0.0") 592 .Set("version", "1.0.0")
583 .Set("manifest_version", 2) 593 .Set("manifest_version", 2)
584 .Set("permissions", std::move(extensions::ListBuilder().Append( 594 .Set("permissions",
585 "fileBrowserHandler"))) 595 extensions::ListBuilder().Append("fileBrowserHandler").Build())
586 .Set("file_browser_handlers", 596 .Set("file_browser_handlers",
587 std::move(extensions::ListBuilder().Append(std::move( 597 extensions::ListBuilder()
588 extensions::DictionaryBuilder() 598 .Append(
589 .Set("id", "open") 599 extensions::DictionaryBuilder()
590 .Set("default_title", "open") 600 .Set("id", "open")
591 .Set("file_filters", 601 .Set("default_title", "open")
592 std::move(extensions::ListBuilder().Append( 602 .Set("file_filters", extensions::ListBuilder()
593 "filesystem:*.txt"))))))))); 603 .Append("filesystem:*.txt")
604 .Build())
605 .Build())
606 .Build())
607 .Build());
594 bar_app.SetID(kBarId); 608 bar_app.SetID(kBarId);
595 extension_service_->AddExtension(bar_app.Build().get()); 609 extension_service_->AddExtension(bar_app.Build().get());
596 610
597 // Find apps for a ".txt" file. Foo.app and Bar.app should be found. 611 // Find apps for a ".txt" file. Foo.app and Bar.app should be found.
598 std::vector<GURL> file_urls; 612 std::vector<GURL> file_urls;
599 file_urls.push_back(GURL("filesystem:chrome-extension://id/dir/foo.txt")); 613 file_urls.push_back(GURL("filesystem:chrome-extension://id/dir/foo.txt"));
600 614
601 std::vector<FullTaskDescriptor> tasks; 615 std::vector<FullTaskDescriptor> tasks;
602 FindFileBrowserHandlerTasks(&test_profile_, file_urls, &tasks); 616 FindFileBrowserHandlerTasks(&test_profile_, file_urls, &tasks);
603 ASSERT_EQ(2U, tasks.size()); 617 ASSERT_EQ(2U, tasks.size());
(...skipping 28 matching lines...) Expand all
632 // app) are returned. 646 // app) are returned.
633 TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks) { 647 TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks) {
634 // kFooId and kBarId copied from FindFileHandlerTasks test above. 648 // kFooId and kBarId copied from FindFileHandlerTasks test above.
635 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; 649 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
636 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; 650 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
637 const char kBazId[] = "plifkpkakemokpflgbnnigcoldgcbdmc"; 651 const char kBazId[] = "plifkpkakemokpflgbnnigcoldgcbdmc";
638 652
639 // Foo.app can handle "text/plain". 653 // Foo.app can handle "text/plain".
640 // This is a packaged app (file handler). 654 // This is a packaged app (file handler).
641 extensions::ExtensionBuilder foo_app; 655 extensions::ExtensionBuilder foo_app;
642 foo_app.SetManifest(std::move( 656 foo_app.SetManifest(
643 extensions::DictionaryBuilder() 657 extensions::DictionaryBuilder()
644 .Set("name", "Foo") 658 .Set("name", "Foo")
645 .Set("version", "1.0.0") 659 .Set("version", "1.0.0")
646 .Set("manifest_version", 2) 660 .Set("manifest_version", 2)
647 .Set("app", 661 .Set("app", extensions::DictionaryBuilder()
648 std::move(extensions::DictionaryBuilder().Set( 662 .Set("background",
649 "background", 663 extensions::DictionaryBuilder()
650 std::move(extensions::DictionaryBuilder().Set( 664 .Set("scripts", extensions::ListBuilder()
651 "scripts", std::move(extensions::ListBuilder().Append( 665 .Append("background.js")
652 "background.js"))))))) 666 .Build())
653 .Set( 667 .Build())
654 "file_handlers", 668 .Build())
655 std::move(extensions::DictionaryBuilder().Set( 669 .Set("file_handlers",
656 "text", 670 extensions::DictionaryBuilder()
657 std::move(extensions::DictionaryBuilder() 671 .Set("text", extensions::DictionaryBuilder()
658 .Set("title", "Text") 672 .Set("title", "Text")
659 .Set("types", 673 .Set("types", extensions::ListBuilder()
660 std::move(extensions::ListBuilder().Append( 674 .Append("text/plain")
661 "text/plain"))))))))); 675 .Build())
676 .Build())
677 .Build())
678 .Build());
662 foo_app.SetID(kFooId); 679 foo_app.SetID(kFooId);
663 extension_service_->AddExtension(foo_app.Build().get()); 680 extension_service_->AddExtension(foo_app.Build().get());
664 681
665 // Bar.app can only handle ".txt". 682 // Bar.app can only handle ".txt".
666 // This is an extension (file browser handler). 683 // This is an extension (file browser handler).
667 extensions::ExtensionBuilder bar_app; 684 extensions::ExtensionBuilder bar_app;
668 bar_app.SetManifest(std::move( 685 bar_app.SetManifest(
669 extensions::DictionaryBuilder() 686 extensions::DictionaryBuilder()
670 .Set("name", "Bar") 687 .Set("name", "Bar")
671 .Set("version", "1.0.0") 688 .Set("version", "1.0.0")
672 .Set("manifest_version", 2) 689 .Set("manifest_version", 2)
673 .Set("permissions", std::move(extensions::ListBuilder().Append( 690 .Set("permissions",
674 "fileBrowserHandler"))) 691 extensions::ListBuilder().Append("fileBrowserHandler").Build())
675 .Set("file_browser_handlers", 692 .Set("file_browser_handlers",
676 std::move(extensions::ListBuilder().Append(std::move( 693 extensions::ListBuilder()
677 extensions::DictionaryBuilder() 694 .Append(
678 .Set("id", "open") 695 extensions::DictionaryBuilder()
679 .Set("default_title", "open") 696 .Set("id", "open")
680 .Set("file_filters", 697 .Set("default_title", "open")
681 std::move(extensions::ListBuilder().Append( 698 .Set("file_filters", extensions::ListBuilder()
682 "filesystem:*.txt"))))))))); 699 .Append("filesystem:*.txt")
700 .Build())
701 .Build())
702 .Build())
703 .Build());
683 bar_app.SetID(kBarId); 704 bar_app.SetID(kBarId);
684 extension_service_->AddExtension(bar_app.Build().get()); 705 extension_service_->AddExtension(bar_app.Build().get());
685 706
686 // Baz.app can handle "text/plain". 707 // Baz.app can handle "text/plain".
687 // This is a Drive app. 708 // This is a Drive app.
688 scoped_ptr<google_apis::AppResource> baz_app(new google_apis::AppResource); 709 scoped_ptr<google_apis::AppResource> baz_app(new google_apis::AppResource);
689 baz_app->set_product_id("baz_app_id"); 710 baz_app->set_product_id("baz_app_id");
690 baz_app->set_application_id(kBazId); 711 baz_app->set_application_id(kBazId);
691 baz_app->set_name("Baz"); 712 baz_app->set_name("Baz");
692 baz_app->set_object_type("baz_object_type"); 713 baz_app->set_object_type("baz_object_type");
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 ScopedVector<google_apis::AppResource> app_resources; 767 ScopedVector<google_apis::AppResource> app_resources;
747 app_resources.push_back(foo_app.release()); 768 app_resources.push_back(foo_app.release());
748 google_apis::AppList app_list; 769 google_apis::AppList app_list;
749 app_list.set_items(std::move(app_resources)); 770 app_list.set_items(std::move(app_resources));
750 drive::DriveAppRegistry drive_app_registry(NULL); 771 drive::DriveAppRegistry drive_app_registry(NULL);
751 drive_app_registry.UpdateFromAppList(app_list); 772 drive_app_registry.UpdateFromAppList(app_list);
752 773
753 // Bar.app can handle ".gdoc" files. 774 // Bar.app can handle ".gdoc" files.
754 // This is an extension (file browser handler). 775 // This is an extension (file browser handler).
755 extensions::ExtensionBuilder bar_app; 776 extensions::ExtensionBuilder bar_app;
756 bar_app.SetManifest(std::move( 777 bar_app.SetManifest(
757 extensions::DictionaryBuilder() 778 extensions::DictionaryBuilder()
758 .Set("name", "Bar") 779 .Set("name", "Bar")
759 .Set("version", "1.0.0") 780 .Set("version", "1.0.0")
760 .Set("manifest_version", 2) 781 .Set("manifest_version", 2)
761 .Set("permissions", std::move(extensions::ListBuilder().Append( 782 .Set("permissions",
762 "fileBrowserHandler"))) 783 extensions::ListBuilder().Append("fileBrowserHandler").Build())
763 .Set("file_browser_handlers", 784 .Set("file_browser_handlers",
764 std::move(extensions::ListBuilder().Append(std::move( 785 extensions::ListBuilder()
765 extensions::DictionaryBuilder() 786 .Append(
766 .Set("id", "open") 787 extensions::DictionaryBuilder()
767 .Set("default_title", "open") 788 .Set("id", "open")
768 .Set("file_filters", 789 .Set("default_title", "open")
769 std::move(extensions::ListBuilder().Append( 790 .Set("file_filters", extensions::ListBuilder()
770 "filesystem:*.gdoc"))))))))); 791 .Append("filesystem:*.gdoc")
792 .Build())
793 .Build())
794 .Build())
795 .Build());
771 bar_app.SetID(kBarId); 796 bar_app.SetID(kBarId);
772 extension_service_->AddExtension(bar_app.Build().get()); 797 extension_service_->AddExtension(bar_app.Build().get());
773 798
774 // Files.app can handle ".gdoc" files. 799 // Files.app can handle ".gdoc" files.
775 // The ID "kFileManagerAppId" used here is precisely the one that identifies 800 // The ID "kFileManagerAppId" used here is precisely the one that identifies
776 // the Chrome OS Files.app application. 801 // the Chrome OS Files.app application.
777 extensions::ExtensionBuilder files_app; 802 extensions::ExtensionBuilder files_app;
778 files_app.SetManifest(std::move( 803 files_app.SetManifest(
779 extensions::DictionaryBuilder() 804 extensions::DictionaryBuilder()
780 .Set("name", "Files") 805 .Set("name", "Files")
781 .Set("version", "1.0.0") 806 .Set("version", "1.0.0")
782 .Set("manifest_version", 2) 807 .Set("manifest_version", 2)
783 .Set("permissions", std::move(extensions::ListBuilder().Append( 808 .Set("permissions",
784 "fileBrowserHandler"))) 809 extensions::ListBuilder().Append("fileBrowserHandler").Build())
785 .Set("file_browser_handlers", 810 .Set("file_browser_handlers",
786 std::move(extensions::ListBuilder().Append(std::move( 811 extensions::ListBuilder()
787 extensions::DictionaryBuilder() 812 .Append(
788 .Set("id", "open") 813 extensions::DictionaryBuilder()
789 .Set("default_title", "open") 814 .Set("id", "open")
790 .Set("file_filters", 815 .Set("default_title", "open")
791 std::move(extensions::ListBuilder().Append( 816 .Set("file_filters", extensions::ListBuilder()
792 "filesystem:*.gdoc"))))))))); 817 .Append("filesystem:*.gdoc")
818 .Build())
819 .Build())
820 .Build())
821 .Build());
793 files_app.SetID(kFileManagerAppId); 822 files_app.SetID(kFileManagerAppId);
794 extension_service_->AddExtension(files_app.Build().get()); 823 extension_service_->AddExtension(files_app.Build().get());
795 824
796 // Find apps for a ".gdoc file". Only the built-in handler of Files.apps 825 // Find apps for a ".gdoc file". Only the built-in handler of Files.apps
797 // should be found. 826 // should be found.
798 std::vector<extensions::EntryInfo> entries; 827 std::vector<extensions::EntryInfo> entries;
799 std::vector<GURL> file_urls; 828 std::vector<GURL> file_urls;
800 entries.push_back( 829 entries.push_back(
801 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) 830 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_)
802 .AppendASCII("foo.gdoc"), 831 .AppendASCII("foo.gdoc"),
(...skipping 10 matching lines...) Expand all
813 TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) { 842 TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) {
814 // Since we want to keep the order of the result as foo,bar,baz,qux, 843 // Since we want to keep the order of the result as foo,bar,baz,qux,
815 // keep the ids in alphabetical order. 844 // keep the ids in alphabetical order.
816 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; 845 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
817 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; 846 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
818 const char kBazId[] = "plifkpkakemokpflgbnnigcoldgcbdmc"; 847 const char kBazId[] = "plifkpkakemokpflgbnnigcoldgcbdmc";
819 const char kQuxId[] = "pmifkpkakgkadkkhcmhgnigmmifgpaph"; 848 const char kQuxId[] = "pmifkpkakgkadkkhcmhgnigmmifgpaph";
820 849
821 // Foo app provides file handler for text/plain and all file types. 850 // Foo app provides file handler for text/plain and all file types.
822 extensions::ExtensionBuilder foo_app; 851 extensions::ExtensionBuilder foo_app;
823 foo_app.SetManifest(std::move( 852 foo_app.SetManifest(
824 extensions::DictionaryBuilder() 853 extensions::DictionaryBuilder()
825 .Set("name", "Foo") 854 .Set("name", "Foo")
826 .Set("version", "1.0.0") 855 .Set("version", "1.0.0")
827 .Set("manifest_version", 2) 856 .Set("manifest_version", 2)
828 .Set("app", 857 .Set("app", extensions::DictionaryBuilder()
829 std::move(extensions::DictionaryBuilder().Set( 858 .Set("background",
830 "background", 859 extensions::DictionaryBuilder()
831 std::move(extensions::DictionaryBuilder().Set( 860 .Set("scripts", extensions::ListBuilder()
832 "scripts", std::move(extensions::ListBuilder().Append( 861 .Append("background.js")
833 "background.js"))))))) 862 .Build())
834 .Set("file_handlers", 863 .Build())
835 std::move( 864 .Build())
836 extensions::DictionaryBuilder() 865 .Set(
837 .Set("any", 866 "file_handlers",
838 std::move(extensions::DictionaryBuilder().Set( 867 extensions::DictionaryBuilder()
839 "types", std::move(extensions::ListBuilder() 868 .Set("any",
840 .Append("*/*"))))) 869 extensions::DictionaryBuilder()
841 .Set("text", 870 .Set("types",
842 std::move(extensions::DictionaryBuilder().Set( 871 extensions::ListBuilder().Append("*/*").Build())
843 "types", 872 .Build())
844 std::move(extensions::ListBuilder().Append( 873 .Set("text", extensions::DictionaryBuilder()
845 "text/plain"))))))))); 874 .Set("types", extensions::ListBuilder()
875 .Append("text/plain")
876 .Build())
877 .Build())
878 .Build())
879 .Build());
846 foo_app.SetID(kFooId); 880 foo_app.SetID(kFooId);
847 extension_service_->AddExtension(foo_app.Build().get()); 881 extension_service_->AddExtension(foo_app.Build().get());
848 882
849 // Bar app provides file handler for .txt and not provide generic file 883 // Bar app provides file handler for .txt and not provide generic file
850 // handler, but handles directories. 884 // handler, but handles directories.
851 extensions::ExtensionBuilder bar_app; 885 extensions::ExtensionBuilder bar_app;
852 bar_app.SetManifest(std::move( 886 bar_app.SetManifest(
853 extensions::DictionaryBuilder() 887 extensions::DictionaryBuilder()
854 .Set("name", "Bar") 888 .Set("name", "Bar")
855 .Set("version", "1.0.0") 889 .Set("version", "1.0.0")
856 .Set("manifest_version", 2) 890 .Set("manifest_version", 2)
857 .Set("app", 891 .Set("app", extensions::DictionaryBuilder()
858 std::move(extensions::DictionaryBuilder().Set( 892 .Set("background",
859 "background", 893 extensions::DictionaryBuilder()
860 std::move(extensions::DictionaryBuilder().Set( 894 .Set("scripts", extensions::ListBuilder()
861 "scripts", std::move(extensions::ListBuilder().Append( 895 .Append("background.js")
862 "background.js"))))))) 896 .Build())
897 .Build())
898 .Build())
863 .Set( 899 .Set(
864 "file_handlers", 900 "file_handlers",
865 std::move(extensions::DictionaryBuilder().Set( 901 extensions::DictionaryBuilder()
866 "text", 902 .Set("text",
867 std::move(extensions::DictionaryBuilder() 903 extensions::DictionaryBuilder()
868 .SetBoolean("include_directories", true) 904 .SetBoolean("include_directories", true)
869 .Set("extensions", 905 .Set("extensions",
870 std::move(extensions::ListBuilder().Append( 906 extensions::ListBuilder().Append("txt").Build())
871 "txt"))))))))); 907 .Build())
908 .Build())
909 .Build());
872 bar_app.SetID(kBarId); 910 bar_app.SetID(kBarId);
873 extension_service_->AddExtension(bar_app.Build().get()); 911 extension_service_->AddExtension(bar_app.Build().get());
874 912
875 // Baz app provides file handler for all extensions and images. 913 // Baz app provides file handler for all extensions and images.
876 extensions::ExtensionBuilder baz_app; 914 extensions::ExtensionBuilder baz_app;
877 baz_app.SetManifest(std::move( 915 baz_app.SetManifest(
878 extensions::DictionaryBuilder() 916 extensions::DictionaryBuilder()
879 .Set("name", "Baz") 917 .Set("name", "Baz")
880 .Set("version", "1.0.0") 918 .Set("version", "1.0.0")
881 .Set("manifest_version", 2) 919 .Set("manifest_version", 2)
882 .Set("app", 920 .Set("app", extensions::DictionaryBuilder()
883 std::move(extensions::DictionaryBuilder().Set( 921 .Set("background",
884 "background", 922 extensions::DictionaryBuilder()
885 std::move(extensions::DictionaryBuilder().Set( 923 .Set("scripts", extensions::ListBuilder()
886 "scripts", std::move(extensions::ListBuilder().Append( 924 .Append("background.js")
887 "background.js"))))))) 925 .Build())
888 .Set( 926 .Build())
889 "file_handlers", 927 .Build())
890 std::move( 928 .Set("file_handlers",
891 extensions::DictionaryBuilder() 929 extensions::DictionaryBuilder()
892 .Set("any", 930 .Set("any", extensions::DictionaryBuilder()
893 std::move(extensions::DictionaryBuilder().Set( 931 .Set("extensions", extensions::ListBuilder()
894 "extensions", std::move(extensions::ListBuilder() 932 .Append("*")
895 .Append("*") 933 .Append("bar")
896 .Append("bar"))))) 934 .Build())
897 .Set("image", 935 .Build())
898 std::move(extensions::DictionaryBuilder().Set( 936 .Set("image", extensions::DictionaryBuilder()
899 "types", 937 .Set("types", extensions::ListBuilder()
900 std::move(extensions::ListBuilder().Append( 938 .Append("image/*")
901 "image/*"))))))))); 939 .Build())
940 .Build())
941 .Build())
942 .Build());
902 baz_app.SetID(kBazId); 943 baz_app.SetID(kBazId);
903 extension_service_->AddExtension(baz_app.Build().get()); 944 extension_service_->AddExtension(baz_app.Build().get());
904 945
905 // Qux app provides file handler for all types. 946 // Qux app provides file handler for all types.
906 extensions::ExtensionBuilder qux_app; 947 extensions::ExtensionBuilder qux_app;
907 qux_app.SetManifest(std::move( 948 qux_app.SetManifest(
908 extensions::DictionaryBuilder() 949 extensions::DictionaryBuilder()
909 .Set("name", "Qux") 950 .Set("name", "Qux")
910 .Set("version", "1.0.0") 951 .Set("version", "1.0.0")
911 .Set("manifest_version", 2) 952 .Set("manifest_version", 2)
912 .Set("app", 953 .Set("app", extensions::DictionaryBuilder()
913 std::move(extensions::DictionaryBuilder().Set( 954 .Set("background",
914 "background", 955 extensions::DictionaryBuilder()
915 std::move(extensions::DictionaryBuilder().Set( 956 .Set("scripts", extensions::ListBuilder()
916 "scripts", std::move(extensions::ListBuilder().Append( 957 .Append("background.js")
917 "background.js"))))))) 958 .Build())
959 .Build())
960 .Build())
918 .Set("file_handlers", 961 .Set("file_handlers",
919 std::move(extensions::DictionaryBuilder().Set( 962 extensions::DictionaryBuilder()
920 "any", 963 .Set("any",
921 std::move(extensions::DictionaryBuilder().Set( 964 extensions::DictionaryBuilder()
922 "types", 965 .Set("types",
923 std::move(extensions::ListBuilder().Append("*"))))))))); 966 extensions::ListBuilder().Append("*").Build())
967 .Build())
968 .Build())
969 .Build());
924 qux_app.SetID(kQuxId); 970 qux_app.SetID(kQuxId);
925 extension_service_->AddExtension(qux_app.Build().get()); 971 extension_service_->AddExtension(qux_app.Build().get());
926 972
927 // Test case with .txt file 973 // Test case with .txt file
928 std::vector<extensions::EntryInfo> txt_entries; 974 std::vector<extensions::EntryInfo> txt_entries;
929 txt_entries.push_back( 975 txt_entries.push_back(
930 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) 976 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_)
931 .AppendASCII("foo.txt"), 977 .AppendASCII("foo.txt"),
932 "text/plain", false)); 978 "text/plain", false));
933 std::vector<FullTaskDescriptor> txt_result; 979 std::vector<FullTaskDescriptor> txt_result;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 std::vector<FullTaskDescriptor> dir_result; 1020 std::vector<FullTaskDescriptor> dir_result;
975 FindFileHandlerTasks(&test_profile_, dir_entries, &dir_result); 1021 FindFileHandlerTasks(&test_profile_, dir_entries, &dir_result);
976 ASSERT_EQ(1U, dir_result.size()); 1022 ASSERT_EQ(1U, dir_result.size());
977 // Confirm that only Bar.app is found and that it is a generic file handler. 1023 // Confirm that only Bar.app is found and that it is a generic file handler.
978 EXPECT_EQ(kBarId, dir_result[0].task_descriptor().app_id); 1024 EXPECT_EQ(kBarId, dir_result[0].task_descriptor().app_id);
979 EXPECT_TRUE(dir_result[0].is_generic_file_handler()); 1025 EXPECT_TRUE(dir_result[0].is_generic_file_handler());
980 } 1026 }
981 1027
982 } // namespace file_tasks 1028 } // namespace file_tasks
983 } // namespace file_manager. 1029 } // namespace file_manager.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698