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

Side by Side Diff: services/catalog/entry_unittest.cc

Issue 2684433003: Files required by a service now listed in manifest. (Closed)
Patch Set: Fix build. Created 3 years, 10 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
« no previous file with comments | « services/catalog/entry.cc ('k') | services/catalog/public/cpp/BUILD.gn » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/catalog/entry.h" 5 #include "services/catalog/entry.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 EXPECT_EQ("Foo", entry->display_name()); 71 EXPECT_EQ("Foo", entry->display_name());
72 service_manager::InterfaceProviderSpec spec; 72 service_manager::InterfaceProviderSpec spec;
73 service_manager::CapabilitySet capabilities; 73 service_manager::CapabilitySet capabilities;
74 capabilities.insert("bar:bar"); 74 capabilities.insert("bar:bar");
75 spec.requires["bar"] = capabilities; 75 spec.requires["bar"] = capabilities;
76 service_manager::InterfaceProviderSpecMap specs; 76 service_manager::InterfaceProviderSpecMap specs;
77 specs[service_manager::mojom::kServiceManager_ConnectorSpec] = spec; 77 specs[service_manager::mojom::kServiceManager_ConnectorSpec] = spec;
78 EXPECT_EQ(specs, entry->interface_provider_specs()); 78 EXPECT_EQ(specs, entry->interface_provider_specs());
79 } 79 }
80 80
81 TEST_F(EntryTest, Serialization) { 81 TEST_F(EntryTest, RequiredFiles) {
82 std::unique_ptr<base::Value> value; 82 std::unique_ptr<Entry> entry = ReadEntry("required_files", nullptr);
83 std::unique_ptr<Entry> entry = ReadEntry("serialization", &value); 83 EXPECT_EQ("foo", entry->name());
84 84 EXPECT_EQ("Foo", entry->display_name());
85 std::unique_ptr<base::DictionaryValue> serialized(entry->Serialize()); 85 auto required_files = entry->required_file_paths();
86 86 EXPECT_EQ(2U, required_files.size());
87 // We can't just compare values, since during deserialization some of the 87 auto iter = required_files.find("all_platforms");
88 // lists get converted to std::sets, which are sorted, so Value::Equals will 88 ASSERT_NE(required_files.end(), iter);
89 // fail. 89 bool checked_platform_specific_file = false;
90 std::unique_ptr<Entry> reconstituted = Entry::Deserialize(*serialized.get()); 90 #if defined(OS_WIN)
91 EXPECT_EQ(*entry, *reconstituted); 91 EXPECT_EQ(base::FilePath(L"/all/platforms/windows"), iter->second);
92 iter = required_files.find("windows_only");
93 ASSERT_NE(required_files.end(), iter);
94 EXPECT_EQ(base::FilePath(L"/windows/only"), iter->second);
95 checked_platform_specific_file = true;
96 #elif defined(OS_LINUX)
97 EXPECT_EQ(base::FilePath("/all/platforms/linux"), iter->second);
98 iter = required_files.find("linux_only");
99 ASSERT_NE(required_files.end(), iter);
100 EXPECT_EQ(base::FilePath("/linux/only"), iter->second);
101 checked_platform_specific_file = true;
102 #elif defined(OS_MACOSX)
103 EXPECT_EQ(base::FilePath("/all/platforms/macosx"), iter->second);
104 iter = required_files.find("macosx_only");
105 ASSERT_NE(required_files.end(), iter);
106 EXPECT_EQ(base::FilePath("/macosx/only"), iter->second);
107 checked_platform_specific_file = true;
108 #elif defined(OS_ANDROID)
109 EXPECT_EQ(base::FilePath("/all/platforms/android"), iter->second);
110 iter = required_files.find("android_only");
111 ASSERT_NE(required_files.end(), iter);
112 EXPECT_EQ(base::FilePath("/android/only"), iter->second);
113 checked_platform_specific_file = true;
114 #endif
115 EXPECT_TRUE(checked_platform_specific_file);
92 } 116 }
93 117
94 TEST_F(EntryTest, Malformed) { 118 TEST_F(EntryTest, Malformed) {
95 std::unique_ptr<base::Value> value = ReadManifest("malformed"); 119 std::unique_ptr<base::Value> value = ReadManifest("malformed");
96 EXPECT_FALSE(value.get()); 120 EXPECT_FALSE(value.get());
97 } 121 }
98 122
99 123
100 } // namespace catalog 124 } // namespace catalog
OLDNEW
« no previous file with comments | « services/catalog/entry.cc ('k') | services/catalog/public/cpp/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698