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

Side by Side Diff: url/mojo/mojo_gurl_unittest.cc

Issue 1760643004: Add mojo struct traits for GURL so that it can be sent over mojoms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to mojom namespace and add security owners 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "base/macros.h"
7 #include "mojo/public/cpp/bindings/binding.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "url/mojo/url_test.mojom.h"
10
11 namespace url {
12
13 class UrlTestImpl : public mojom::UrlTest {
14 public:
15 explicit UrlTestImpl(mojo::InterfaceRequest<url::mojom::UrlTest> request)
16 : binding_(this, std::move(request)) {
17 }
18
19 // UrlTest:
20 void Bounce(const GURL& in, const BounceCallback& callback) override {
21 callback.Run(in);
22 }
23
24 private:
25 mojo::Binding<UrlTest> binding_;
26 };
27
28 // Mojo version of chrome IPC test in
29 // content/common/common_param_traits_unittest.cc
30 TEST(MojoGURLTest, Basic) {
31 base::MessageLoop message_loop;
32
33 mojom::UrlTestPtr proxy;
34 UrlTestImpl impl(GetProxy(&proxy));
35
36 const char* serialize_cases[] = {
37 "http://www.google.com/",
38 "http://user:pass@host.com:888/foo;bar?baz#nop",
39 };
40
41 for (size_t i = 0; i < arraysize(serialize_cases); i++) {
42 GURL input(serialize_cases[i]);
43 GURL output;
44 EXPECT_TRUE(proxy->Bounce(input, &output));
45
46 // We want to test each component individually to make sure its range was
47 // correctly serialized and deserialized, not just the spec.
48 EXPECT_EQ(input.possibly_invalid_spec(), output.possibly_invalid_spec());
49 EXPECT_EQ(input.is_valid(), output.is_valid());
50 EXPECT_EQ(input.scheme(), output.scheme());
51 EXPECT_EQ(input.username(), output.username());
52 EXPECT_EQ(input.password(), output.password());
53 EXPECT_EQ(input.host(), output.host());
54 EXPECT_EQ(input.port(), output.port());
55 EXPECT_EQ(input.path(), output.path());
56 EXPECT_EQ(input.query(), output.query());
57 EXPECT_EQ(input.ref(), output.ref());
58 }
59
60 // Test an excessively long GURL.
61 {
62 const std::string url = std::string("http://example.org/").append(
63 mojo::kMaxURLChars + 1, 'a');
64 GURL input(url.c_str());
65 GURL output;
66 EXPECT_TRUE(proxy->Bounce(input, &output));
67 EXPECT_TRUE(output.is_empty());
68 }
69 }
70
71 } // namespace url
OLDNEW
« no previous file with comments | « url/mojo/gurl.typemap ('k') | url/mojo/url.mojom » ('j') | url/mojo/url_gurl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698