| OLD | NEW |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 void SetUp() override {} | 50 void SetUp() override {} |
| 51 void TearDown() override {} | 51 void TearDown() override {} |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(EntryTest); | 53 DISALLOW_COPY_AND_ASSIGN(EntryTest); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 TEST_F(EntryTest, Simple) { | 56 TEST_F(EntryTest, Simple) { |
| 57 std::unique_ptr<Entry> entry = ReadEntry("simple", nullptr); | 57 std::unique_ptr<Entry> entry = ReadEntry("simple", nullptr); |
| 58 EXPECT_EQ("mojo:foo", entry->name()); | 58 EXPECT_EQ("service:foo", entry->name()); |
| 59 EXPECT_EQ(shell::GetNamePath(entry->name()), entry->qualifier()); | 59 EXPECT_EQ(shell::GetNamePath(entry->name()), entry->qualifier()); |
| 60 EXPECT_EQ("Foo", entry->display_name()); | 60 EXPECT_EQ("Foo", entry->display_name()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 TEST_F(EntryTest, NoWildcardInInterfaces) { | 63 TEST_F(EntryTest, NoWildcardInInterfaces) { |
| 64 std::unique_ptr<Entry> entry = ReadEntry("wildcard_interfaces", nullptr); | 64 std::unique_ptr<Entry> entry = ReadEntry("wildcard_interfaces", nullptr); |
| 65 EXPECT_EQ(nullptr, entry.get()); | 65 EXPECT_EQ(nullptr, entry.get()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 TEST_F(EntryTest, Instance) { | 68 TEST_F(EntryTest, Instance) { |
| 69 std::unique_ptr<Entry> entry = ReadEntry("instance", nullptr); | 69 std::unique_ptr<Entry> entry = ReadEntry("instance", nullptr); |
| 70 EXPECT_EQ("mojo:foo", entry->name()); | 70 EXPECT_EQ("service:foo", entry->name()); |
| 71 EXPECT_EQ("bar", entry->qualifier()); | 71 EXPECT_EQ("bar", entry->qualifier()); |
| 72 EXPECT_EQ("Foo", entry->display_name()); | 72 EXPECT_EQ("Foo", entry->display_name()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(EntryTest, Capabilities) { | 75 TEST_F(EntryTest, Capabilities) { |
| 76 std::unique_ptr<Entry> entry = ReadEntry("capabilities", nullptr); | 76 std::unique_ptr<Entry> entry = ReadEntry("capabilities", nullptr); |
| 77 | 77 |
| 78 EXPECT_EQ("mojo:foo", entry->name()); | 78 EXPECT_EQ("service:foo", entry->name()); |
| 79 EXPECT_EQ("bar", entry->qualifier()); | 79 EXPECT_EQ("bar", entry->qualifier()); |
| 80 EXPECT_EQ("Foo", entry->display_name()); | 80 EXPECT_EQ("Foo", entry->display_name()); |
| 81 shell::CapabilitySpec spec; | 81 shell::CapabilitySpec spec; |
| 82 shell::CapabilityRequest request; | 82 shell::CapabilityRequest request; |
| 83 request.interfaces.insert("mojo::Bar"); | 83 request.interfaces.insert("mojo::Bar"); |
| 84 spec.required["mojo:bar"] = request; | 84 spec.required["service:bar"] = request; |
| 85 EXPECT_EQ(spec, entry->capabilities()); | 85 EXPECT_EQ(spec, entry->capabilities()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST_F(EntryTest, Serialization) { | 88 TEST_F(EntryTest, Serialization) { |
| 89 std::unique_ptr<base::Value> value; | 89 std::unique_ptr<base::Value> value; |
| 90 std::unique_ptr<Entry> entry = ReadEntry("serialization", &value); | 90 std::unique_ptr<Entry> entry = ReadEntry("serialization", &value); |
| 91 | 91 |
| 92 std::unique_ptr<base::DictionaryValue> serialized(entry->Serialize()); | 92 std::unique_ptr<base::DictionaryValue> serialized(entry->Serialize()); |
| 93 | 93 |
| 94 // We can't just compare values, since during deserialization some of the | 94 // We can't just compare values, since during deserialization some of the |
| 95 // lists get converted to std::sets, which are sorted, so Value::Equals will | 95 // lists get converted to std::sets, which are sorted, so Value::Equals will |
| 96 // fail. | 96 // fail. |
| 97 std::unique_ptr<Entry> reconstituted = Entry::Deserialize(*serialized.get()); | 97 std::unique_ptr<Entry> reconstituted = Entry::Deserialize(*serialized.get()); |
| 98 EXPECT_EQ(*entry, *reconstituted); | 98 EXPECT_EQ(*entry, *reconstituted); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TEST_F(EntryTest, Malformed) { | 101 TEST_F(EntryTest, Malformed) { |
| 102 std::unique_ptr<base::Value> value = ReadManifest("malformed"); | 102 std::unique_ptr<base::Value> value = ReadManifest("malformed"); |
| 103 EXPECT_FALSE(value.get()); | 103 EXPECT_FALSE(value.get()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 | 106 |
| 107 } // namespace catalog | 107 } // namespace catalog |
| OLD | NEW |