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

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

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Created 3 years, 11 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 TestingProfile profile; 174 TestingProfile profile;
175 175
176 // Foo.app can handle "text/plain" and "text/html" 176 // Foo.app can handle "text/plain" and "text/html"
177 std::unique_ptr<google_apis::AppResource> foo_app( 177 std::unique_ptr<google_apis::AppResource> foo_app(
178 new google_apis::AppResource); 178 new google_apis::AppResource);
179 foo_app->set_product_id("foo_app_id"); 179 foo_app->set_product_id("foo_app_id");
180 foo_app->set_application_id("foo_app_id"); 180 foo_app->set_application_id("foo_app_id");
181 foo_app->set_name("Foo"); 181 foo_app->set_name("Foo");
182 foo_app->set_object_type("foo_object_type"); 182 foo_app->set_object_type("foo_object_type");
183 ScopedVector<std::string> foo_mime_types; 183 std::vector<std::unique_ptr<std::string>> foo_mime_types;
184 foo_mime_types.push_back(new std::string("text/plain")); 184 foo_mime_types.push_back(base::MakeUnique<std::string>("text/plain"));
185 foo_mime_types.push_back(new std::string("text/html")); 185 foo_mime_types.push_back(base::MakeUnique<std::string>("text/html"));
186 foo_app->set_primary_mimetypes(std::move(foo_mime_types)); 186 foo_app->set_primary_mimetypes(std::move(foo_mime_types));
187 187
188 // Bar.app can only handle "text/plain". 188 // Bar.app can only handle "text/plain".
189 std::unique_ptr<google_apis::AppResource> bar_app( 189 std::unique_ptr<google_apis::AppResource> bar_app(
190 new google_apis::AppResource); 190 new google_apis::AppResource);
191 bar_app->set_product_id("bar_app_id"); 191 bar_app->set_product_id("bar_app_id");
192 bar_app->set_application_id("bar_app_id"); 192 bar_app->set_application_id("bar_app_id");
193 bar_app->set_name("Bar"); 193 bar_app->set_name("Bar");
194 bar_app->set_object_type("bar_object_type"); 194 bar_app->set_object_type("bar_object_type");
195 ScopedVector<std::string> bar_mime_types; 195 std::vector<std::unique_ptr<std::string>> bar_mime_types;
196 bar_mime_types.push_back(new std::string("text/plain")); 196 bar_mime_types.push_back(base::MakeUnique<std::string>("text/plain"));
197 bar_app->set_primary_mimetypes(std::move(bar_mime_types)); 197 bar_app->set_primary_mimetypes(std::move(bar_mime_types));
198 198
199 // Prepare DriveAppRegistry from Foo.app and Bar.app. 199 // Prepare DriveAppRegistry from Foo.app and Bar.app.
200 ScopedVector<google_apis::AppResource> app_resources; 200 std::vector<std::unique_ptr<google_apis::AppResource>> app_resources;
201 app_resources.push_back(foo_app.release()); 201 app_resources.push_back(std::move(foo_app));
202 app_resources.push_back(bar_app.release()); 202 app_resources.push_back(std::move(bar_app));
203 google_apis::AppList app_list; 203 google_apis::AppList app_list;
204 app_list.set_items(std::move(app_resources)); 204 app_list.set_items(std::move(app_resources));
205 drive::DriveAppRegistry drive_app_registry(NULL); 205 drive::DriveAppRegistry drive_app_registry(NULL);
206 drive_app_registry.UpdateFromAppList(app_list); 206 drive_app_registry.UpdateFromAppList(app_list);
207 207
208 // Find apps for a "text/plain" file. Foo.app and Bar.app should be found. 208 // Find apps for a "text/plain" file. Foo.app and Bar.app should be found.
209 std::vector<extensions::EntryInfo> entries; 209 std::vector<extensions::EntryInfo> entries;
210 entries.push_back(extensions::EntryInfo( 210 entries.push_back(extensions::EntryInfo(
211 drive::util::GetDriveMountPointPath(&profile).AppendASCII("foo.txt"), 211 drive::util::GetDriveMountPointPath(&profile).AppendASCII("foo.txt"),
212 "text/plain", false)); 212 "text/plain", false));
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 extension_service_->AddExtension(bar_app.Build().get()); 727 extension_service_->AddExtension(bar_app.Build().get());
728 728
729 // Baz.app can handle "text/plain". 729 // Baz.app can handle "text/plain".
730 // This is a Drive app. 730 // This is a Drive app.
731 std::unique_ptr<google_apis::AppResource> baz_app( 731 std::unique_ptr<google_apis::AppResource> baz_app(
732 new google_apis::AppResource); 732 new google_apis::AppResource);
733 baz_app->set_product_id("baz_app_id"); 733 baz_app->set_product_id("baz_app_id");
734 baz_app->set_application_id(kBazId); 734 baz_app->set_application_id(kBazId);
735 baz_app->set_name("Baz"); 735 baz_app->set_name("Baz");
736 baz_app->set_object_type("baz_object_type"); 736 baz_app->set_object_type("baz_object_type");
737 ScopedVector<std::string> baz_mime_types; 737 std::vector<std::unique_ptr<std::string>> baz_mime_types;
738 baz_mime_types.push_back(new std::string("text/plain")); 738 baz_mime_types.push_back(base::MakeUnique<std::string>("text/plain"));
739 baz_app->set_primary_mimetypes(std::move(baz_mime_types)); 739 baz_app->set_primary_mimetypes(std::move(baz_mime_types));
740 // Set up DriveAppRegistry. 740 // Set up DriveAppRegistry.
741 ScopedVector<google_apis::AppResource> app_resources; 741 std::vector<std::unique_ptr<google_apis::AppResource>> app_resources;
742 app_resources.push_back(baz_app.release()); 742 app_resources.push_back(std::move(baz_app));
743 google_apis::AppList app_list; 743 google_apis::AppList app_list;
744 app_list.set_items(std::move(app_resources)); 744 app_list.set_items(std::move(app_resources));
745 drive::DriveAppRegistry drive_app_registry(NULL); 745 drive::DriveAppRegistry drive_app_registry(NULL);
746 drive_app_registry.UpdateFromAppList(app_list); 746 drive_app_registry.UpdateFromAppList(app_list);
747 747
748 // Find apps for "foo.txt". All apps should be found. 748 // Find apps for "foo.txt". All apps should be found.
749 std::vector<extensions::EntryInfo> entries; 749 std::vector<extensions::EntryInfo> entries;
750 std::vector<GURL> file_urls; 750 std::vector<GURL> file_urls;
751 entries.push_back( 751 entries.push_back(
752 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) 752 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_)
(...skipping 23 matching lines...) Expand all
776 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; 776 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
777 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; 777 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
778 778
779 // Foo.app can handle ".gdoc" files. 779 // Foo.app can handle ".gdoc" files.
780 std::unique_ptr<google_apis::AppResource> foo_app( 780 std::unique_ptr<google_apis::AppResource> foo_app(
781 new google_apis::AppResource); 781 new google_apis::AppResource);
782 foo_app->set_product_id("foo_app"); 782 foo_app->set_product_id("foo_app");
783 foo_app->set_application_id(kFooId); 783 foo_app->set_application_id(kFooId);
784 foo_app->set_name("Foo"); 784 foo_app->set_name("Foo");
785 foo_app->set_object_type("foo_object_type"); 785 foo_app->set_object_type("foo_object_type");
786 ScopedVector<std::string> foo_extensions; 786 std::vector<std::unique_ptr<std::string>> foo_extensions;
787 foo_extensions.push_back(new std::string("gdoc")); // Not ".gdoc" 787 foo_extensions.push_back(
788 base::MakeUnique<std::string>("gdoc")); // Not ".gdoc"
788 foo_app->set_primary_file_extensions(std::move(foo_extensions)); 789 foo_app->set_primary_file_extensions(std::move(foo_extensions));
789 790
790 // Prepare DriveAppRegistry from Foo.app. 791 // Prepare DriveAppRegistry from Foo.app.
791 ScopedVector<google_apis::AppResource> app_resources; 792 std::vector<std::unique_ptr<google_apis::AppResource>> app_resources;
792 app_resources.push_back(foo_app.release()); 793 app_resources.push_back(std::move(foo_app));
793 google_apis::AppList app_list; 794 google_apis::AppList app_list;
794 app_list.set_items(std::move(app_resources)); 795 app_list.set_items(std::move(app_resources));
795 drive::DriveAppRegistry drive_app_registry(NULL); 796 drive::DriveAppRegistry drive_app_registry(NULL);
796 drive_app_registry.UpdateFromAppList(app_list); 797 drive_app_registry.UpdateFromAppList(app_list);
797 798
798 // Bar.app can handle ".gdoc" files. 799 // Bar.app can handle ".gdoc" files.
799 // This is an extension (file browser handler). 800 // This is an extension (file browser handler).
800 extensions::ExtensionBuilder bar_app; 801 extensions::ExtensionBuilder bar_app;
801 bar_app.SetManifest( 802 bar_app.SetManifest(
802 extensions::DictionaryBuilder() 803 extensions::DictionaryBuilder()
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 FindFileHandlerTasks(&test_profile_, entries, &tasks); 1179 FindFileHandlerTasks(&test_profile_, entries, &tasks);
1179 1180
1180 ASSERT_EQ(1U, tasks.size()); 1181 ASSERT_EQ(1U, tasks.size());
1181 EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id); 1182 EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id);
1182 EXPECT_EQ("Foo", tasks[0].task_title()); 1183 EXPECT_EQ("Foo", tasks[0].task_title());
1183 EXPECT_EQ(Verb::VERB_PACK_WITH, tasks[0].task_verb()); 1184 EXPECT_EQ(Verb::VERB_PACK_WITH, tasks[0].task_verb());
1184 } 1185 }
1185 1186
1186 } // namespace file_tasks 1187 } // namespace file_tasks
1187 } // namespace file_manager. 1188 } // namespace file_manager.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698