1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "services/network/public/cpp/site_for_cookies_mojom_traits.h"
6 
7 #include "mojo/public/cpp/test_support/test_utils.h"
8 #include "services/network/public/mojom/site_for_cookies.mojom.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h"
11 
12 namespace mojo {
13 
TEST(SiteForCookiesMojomTraitsTest,SerializeAndDeserialize)14 TEST(SiteForCookiesMojomTraitsTest, SerializeAndDeserialize) {
15   std::vector<net::SiteForCookies> keys = {
16       net::SiteForCookies(),
17       net::SiteForCookies::FromUrl(GURL("file:///whatver")),
18       net::SiteForCookies::FromUrl(GURL("ws://127.0.0.1/things")),
19       net::SiteForCookies::FromUrl(GURL("https://example.com"))};
20 
21   for (auto original : keys) {
22     net::SiteForCookies copied;
23     EXPECT_TRUE(
24         mojo::test::SerializeAndDeserialize<network::mojom::SiteForCookies>(
25             &original, &copied));
26     EXPECT_TRUE(original.IsEquivalent(copied));
27     EXPECT_EQ(original.schemefully_same(), copied.schemefully_same());
28   }
29 }
30 
31 }  // namespace mojo
32