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

Unified Diff: mojo/services/catalog/entry_unittest.cc

Issue 1818373003: Move serialize/deserialize logic onto Entry. (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 side-by-side diff with in-line comments
Download patch
« mojo/services/catalog/entry.h ('K') | « mojo/services/catalog/entry.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/catalog/entry_unittest.cc
diff --git a/mojo/services/catalog/builder_unittest.cc b/mojo/services/catalog/entry_unittest.cc
similarity index 69%
rename from mojo/services/catalog/builder_unittest.cc
rename to mojo/services/catalog/entry_unittest.cc
index 1705be892d4cbb9b0f261564181dd89d0f053fde..ae6a5418532fa62f9105410c48f59e5854401a25 100644
--- a/mojo/services/catalog/builder_unittest.cc
+++ b/mojo/services/catalog/entry_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mojo/services/catalog/builder.h"
+#include "mojo/services/catalog/entry.h"
#include "base/files/file_path.h"
#include "base/json/json_file_value_serializer.h"
@@ -15,10 +15,10 @@
namespace catalog {
-class BuilderTest : public testing::Test {
+class EntryTest : public testing::Test {
public:
- BuilderTest() {}
- ~BuilderTest() override {}
+ EntryTest() {}
+ ~EntryTest() override {}
protected:
scoped_ptr<base::Value> ReadEntry(const std::string& manifest, Entry* entry) {
@@ -26,7 +26,7 @@ class BuilderTest : public testing::Test {
scoped_ptr<base::Value> value = ReadManifest(manifest);
base::DictionaryValue* dictionary = nullptr;
CHECK(value->GetAsDictionary(&dictionary));
- *entry = BuildEntry(*dictionary);
+ Entry::Deserialize(*dictionary, entry);
return value;
}
@@ -49,55 +49,56 @@ class BuilderTest : public testing::Test {
void SetUp() override {}
void TearDown() override {}
- DISALLOW_COPY_AND_ASSIGN(BuilderTest);
+ DISALLOW_COPY_AND_ASSIGN(EntryTest);
};
-TEST_F(BuilderTest, Simple) {
+TEST_F(EntryTest, Simple) {
Entry entry;
ReadEntry("simple", &entry);
- EXPECT_EQ("mojo:foo", entry.name);
- EXPECT_EQ(mojo::GetNamePath(entry.name), entry.qualifier);
- EXPECT_EQ("Foo", entry.display_name);
+ EXPECT_EQ("mojo:foo", entry.name());
+ EXPECT_EQ(mojo::GetNamePath(entry.name()), entry.qualifier());
+ EXPECT_EQ("Foo", entry.display_name());
}
-TEST_F(BuilderTest, Instance) {
+TEST_F(EntryTest, Instance) {
Entry entry;
ReadEntry("instance", &entry);
- EXPECT_EQ("mojo:foo", entry.name);
- EXPECT_EQ("bar", entry.qualifier);
- EXPECT_EQ("Foo", entry.display_name);
+ EXPECT_EQ("mojo:foo", entry.name());
+ EXPECT_EQ("bar", entry.qualifier());
+ EXPECT_EQ("Foo", entry.display_name());
}
-TEST_F(BuilderTest, Capabilities) {
+TEST_F(EntryTest, Capabilities) {
Entry entry;
ReadEntry("capabilities", &entry);
- EXPECT_EQ("mojo:foo", entry.name);
- EXPECT_EQ("bar", entry.qualifier);
- EXPECT_EQ("Foo", entry.display_name);
+ EXPECT_EQ("mojo:foo", entry.name());
+ EXPECT_EQ("bar", entry.qualifier());
+ EXPECT_EQ("Foo", entry.display_name());
mojo::CapabilitySpec spec;
mojo::CapabilityRequest request;
request.interfaces.insert("mojo::Bar");
spec.required["mojo:bar"] = request;
- EXPECT_EQ(spec, entry.capabilities);
+ EXPECT_EQ(spec, entry.capabilities());
}
-TEST_F(BuilderTest, Serialization) {
+TEST_F(EntryTest, Serialization) {
Entry entry;
scoped_ptr<base::Value> value = ReadEntry("serialization", &entry);
- scoped_ptr<base::DictionaryValue> serialized(SerializeEntry(entry));
+ scoped_ptr<base::DictionaryValue> serialized(entry.Serialize());
// We can't just compare values, since during deserialization some of the
// lists get converted to std::sets, which are sorted, so Value::Equals will
// fail.
- Entry reconstituted = BuildEntry(*serialized.get());
+ Entry reconstituted;
+ Entry::Deserialize(*serialized.get(), &reconstituted);
EXPECT_EQ(entry, reconstituted);
}
-TEST_F(BuilderTest, Malformed) {
+TEST_F(EntryTest, Malformed) {
scoped_ptr<base::Value> value = ReadManifest("malformed");
EXPECT_FALSE(value.get());
}
« mojo/services/catalog/entry.h ('K') | « mojo/services/catalog/entry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698