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

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

Issue 1497193002: Remove all the ephemeral apps code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests 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
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 <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 base::CommandLine command_line_; 454 base::CommandLine command_line_;
455 ExtensionService* extension_service_; // Owned by test_profile_; 455 ExtensionService* extension_service_; // Owned by test_profile_;
456 }; 456 };
457 457
458 // The basic logic is similar to a test case for FindDriveAppTasks above. 458 // The basic logic is similar to a test case for FindDriveAppTasks above.
459 TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) { 459 TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) {
460 // Random IDs generated by 460 // Random IDs generated by
461 // % ruby -le 'print (0...32).to_a.map{(?a + rand(16)).chr}.join' 461 // % ruby -le 'print (0...32).to_a.map{(?a + rand(16)).chr}.join'
462 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; 462 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
463 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; 463 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
464 const char kEphemeralId[] = "opoomfdlbjcbjinalcjdjfoiikdeaoel";
465 464
466 // Foo.app can handle "text/plain" and "text/html". 465 // Foo.app can handle "text/plain" and "text/html".
467 extensions::ExtensionBuilder foo_app; 466 extensions::ExtensionBuilder foo_app;
468 foo_app.SetManifest(extensions::DictionaryBuilder() 467 foo_app.SetManifest(extensions::DictionaryBuilder()
469 .Set("name", "Foo") 468 .Set("name", "Foo")
470 .Set("version", "1.0.0") 469 .Set("version", "1.0.0")
471 .Set("manifest_version", 2) 470 .Set("manifest_version", 2)
472 .Set("app", 471 .Set("app",
473 extensions::DictionaryBuilder() 472 extensions::DictionaryBuilder()
474 .Set("background", 473 .Set("background",
(...skipping 30 matching lines...) Expand all
505 extensions::DictionaryBuilder() 504 extensions::DictionaryBuilder()
506 .Set("text", 505 .Set("text",
507 extensions::DictionaryBuilder() 506 extensions::DictionaryBuilder()
508 .Set("title", "Text") 507 .Set("title", "Text")
509 .Set("types", 508 .Set("types",
510 extensions::ListBuilder() 509 extensions::ListBuilder()
511 .Append("text/plain"))))); 510 .Append("text/plain")))));
512 bar_app.SetID(kBarId); 511 bar_app.SetID(kBarId);
513 extension_service_->AddExtension(bar_app.Build().get()); 512 extension_service_->AddExtension(bar_app.Build().get());
514 513
515 // Ephemeral.app is an ephemeral app that can handle "text/plain".
516 // It should not ever be found as ephemeral apps cannot be file handlers.
517 extensions::ExtensionBuilder ephemeral_app;
518 ephemeral_app.SetManifest(
519 extensions::DictionaryBuilder()
520 .Set("name", "Ephemeral")
521 .Set("version", "1.0.0")
522 .Set("manifest_version", 2)
523 .Set("app",
524 extensions::DictionaryBuilder().Set(
525 "background",
526 extensions::DictionaryBuilder().Set(
527 "scripts",
528 extensions::ListBuilder().Append("background.js"))))
529 .Set("file_handlers",
530 extensions::DictionaryBuilder().Set(
531 "text",
532 extensions::DictionaryBuilder().Set("title", "Text").Set(
533 "types",
534 extensions::ListBuilder().Append("text/plain")))));
535 ephemeral_app.SetID(kEphemeralId);
536 scoped_refptr<extensions::Extension> built_ephemeral_app(
537 ephemeral_app.Build());
538 extension_service_->AddExtension(built_ephemeral_app.get());
539 extensions::ExtensionPrefs* extension_prefs =
540 extensions::ExtensionPrefs::Get(&test_profile_);
541 extension_prefs->OnExtensionInstalled(built_ephemeral_app.get(),
542 extensions::Extension::ENABLED,
543 syncer::StringOrdinal(),
544 extensions::kInstallFlagIsEphemeral,
545 std::string());
546
547 // Find apps for a "text/plain" file. Foo.app and Bar.app should be found. 514 // Find apps for a "text/plain" file. Foo.app and Bar.app should be found.
548 PathAndMimeTypeSet path_mime_set; 515 PathAndMimeTypeSet path_mime_set;
549 path_mime_set.insert( 516 path_mime_set.insert(
550 std::make_pair( 517 std::make_pair(
551 drive::util::GetDriveMountPointPath(&test_profile_).AppendASCII( 518 drive::util::GetDriveMountPointPath(&test_profile_).AppendASCII(
552 "foo.txt"), 519 "foo.txt"),
553 "text/plain")); 520 "text/plain"));
554 521
555 std::vector<FullTaskDescriptor> tasks; 522 std::vector<FullTaskDescriptor> tasks;
556 FindFileHandlerTasks(&test_profile_, path_mime_set, &tasks); 523 FindFileHandlerTasks(&test_profile_, path_mime_set, &tasks);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 FindFileHandlerTasks(&test_profile_, path_mime_set, &tasks); 558 FindFileHandlerTasks(&test_profile_, path_mime_set, &tasks);
592 // Confirm no tasks are found. 559 // Confirm no tasks are found.
593 ASSERT_TRUE(tasks.empty()); 560 ASSERT_TRUE(tasks.empty());
594 } 561 }
595 562
596 // The basic logic is similar to a test case for FindDriveAppTasks above. 563 // The basic logic is similar to a test case for FindDriveAppTasks above.
597 TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) { 564 TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) {
598 // Copied from FindFileHandlerTasks test above. 565 // Copied from FindFileHandlerTasks test above.
599 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; 566 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
600 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; 567 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
601 const char kEphemeralId[] = "opoomfdlbjcbjinalcjdjfoiikdeaoel";
602 568
603 // Foo.app can handle ".txt" and ".html". 569 // Foo.app can handle ".txt" and ".html".
604 // This one is an extension, and has "file_browser_handlers" 570 // This one is an extension, and has "file_browser_handlers"
605 extensions::ExtensionBuilder foo_app; 571 extensions::ExtensionBuilder foo_app;
606 foo_app.SetManifest( 572 foo_app.SetManifest(
607 extensions::DictionaryBuilder() 573 extensions::DictionaryBuilder()
608 .Set("name", "Foo") 574 .Set("name", "Foo")
609 .Set("version", "1.0.0") 575 .Set("version", "1.0.0")
610 .Set("manifest_version", 2) 576 .Set("manifest_version", 2)
611 .Set("permissions", 577 .Set("permissions",
(...skipping 22 matching lines...) Expand all
634 .Set("file_browser_handlers", 600 .Set("file_browser_handlers",
635 extensions::ListBuilder().Append( 601 extensions::ListBuilder().Append(
636 extensions::DictionaryBuilder() 602 extensions::DictionaryBuilder()
637 .Set("id", "open") 603 .Set("id", "open")
638 .Set("default_title", "open") 604 .Set("default_title", "open")
639 .Set("file_filters", extensions::ListBuilder().Append( 605 .Set("file_filters", extensions::ListBuilder().Append(
640 "filesystem:*.txt"))))); 606 "filesystem:*.txt")))));
641 bar_app.SetID(kBarId); 607 bar_app.SetID(kBarId);
642 extension_service_->AddExtension(bar_app.Build().get()); 608 extension_service_->AddExtension(bar_app.Build().get());
643 609
644 // Ephemeral.app is an ephemeral app that can handle ".txt".
645 // It should not ever be found as ephemeral apps cannot be file browser
646 // handlers.
647 extensions::ExtensionBuilder ephemeral_app;
648 ephemeral_app.SetManifest(
649 extensions::DictionaryBuilder()
650 .Set("name", "Ephemeral")
651 .Set("version", "1.0.0")
652 .Set("manifest_version", 2)
653 .Set("permissions",
654 extensions::ListBuilder().Append("fileBrowserHandler"))
655 .Set("file_browser_handlers",
656 extensions::ListBuilder().Append(
657 extensions::DictionaryBuilder()
658 .Set("id", "open")
659 .Set("default_title", "open")
660 .Set("file_filters", extensions::ListBuilder().Append(
661 "filesystem:*.txt")))));
662 ephemeral_app.SetID(kEphemeralId);
663 scoped_refptr<extensions::Extension> built_ephemeral_app(
664 ephemeral_app.Build());
665 extension_service_->AddExtension(built_ephemeral_app.get());
666 extensions::ExtensionPrefs* extension_prefs =
667 extensions::ExtensionPrefs::Get(&test_profile_);
668 extension_prefs->OnExtensionInstalled(built_ephemeral_app.get(),
669 extensions::Extension::ENABLED,
670 syncer::StringOrdinal(),
671 extensions::kInstallFlagIsEphemeral,
672 std::string());
673
674 // Find apps for a ".txt" file. Foo.app and Bar.app should be found. 610 // Find apps for a ".txt" file. Foo.app and Bar.app should be found.
675 std::vector<GURL> file_urls; 611 std::vector<GURL> file_urls;
676 file_urls.push_back(GURL("filesystem:chrome-extension://id/dir/foo.txt")); 612 file_urls.push_back(GURL("filesystem:chrome-extension://id/dir/foo.txt"));
677 613
678 std::vector<FullTaskDescriptor> tasks; 614 std::vector<FullTaskDescriptor> tasks;
679 FindFileBrowserHandlerTasks(&test_profile_, file_urls, &tasks); 615 FindFileBrowserHandlerTasks(&test_profile_, file_urls, &tasks);
680 ASSERT_EQ(2U, tasks.size()); 616 ASSERT_EQ(2U, tasks.size());
681 // Sort the app IDs, as the order is not guaranteed. 617 // Sort the app IDs, as the order is not guaranteed.
682 std::vector<std::string> app_ids; 618 std::vector<std::string> app_ids;
683 app_ids.push_back(tasks[0].task_descriptor().app_id); 619 app_ids.push_back(tasks[0].task_descriptor().app_id);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 // treated as non-generic handler. 961 // treated as non-generic handler.
1026 EXPECT_EQ("Baz", jpg_result[1].task_title()); 962 EXPECT_EQ("Baz", jpg_result[1].task_title());
1027 EXPECT_FALSE(jpg_result[1].is_generic_file_handler()); 963 EXPECT_FALSE(jpg_result[1].is_generic_file_handler());
1028 // Qux app provides a handler for all types. 964 // Qux app provides a handler for all types.
1029 EXPECT_EQ("Qux", jpg_result[2].task_title()); 965 EXPECT_EQ("Qux", jpg_result[2].task_title());
1030 EXPECT_TRUE(jpg_result[2].is_generic_file_handler()); 966 EXPECT_TRUE(jpg_result[2].is_generic_file_handler());
1031 } 967 }
1032 968
1033 } // namespace file_tasks 969 } // namespace file_tasks
1034 } // namespace file_manager. 970 } // namespace file_manager.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698