Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 <utility> | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/macros.h" | |
| 9 #include "mojo/public/cpp/bindings/binding.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 #include "url/mojo/url_test.mojom.h" | |
| 12 | |
| 13 namespace url { | |
| 14 | |
| 15 class UrlTestImpl : public mojom::UrlTest { | |
| 16 public: | |
| 17 explicit UrlTestImpl(mojo::InterfaceRequest<url::mojom::UrlTest> request) | |
| 18 : binding_(this, std::move(request)) { | |
| 19 } | |
| 20 | |
| 21 // UrlTest: | |
| 22 void Bounce(const GURL& in, const BounceCallback& callback) override { | |
| 23 callback.Run(in); | |
| 24 } | |
| 25 | |
| 26 private: | |
| 27 mojo::Binding<UrlTest> binding_; | |
| 28 }; | |
| 29 | |
| 30 // Mojo version of chrome IPC test in | |
| 31 // content/common/common_param_traits_unittest.cc | |
| 32 TEST(MojoUrlGURLStructTraitsTest, Basic) { | |
| 33 base::MessageLoop message_loop; | |
| 34 | |
| 35 mojom::UrlTestPtr proxy; | |
| 36 UrlTestImpl impl(GetProxy(&proxy)); | |
| 37 | |
| 38 const char* serialize_cases[] = { | |
| 39 "http://www.google.com/", | |
| 40 "http://user:pass@host.com:888/foo;bar?baz#nop", | |
| 41 }; | |
| 42 | |
| 43 for (size_t i = 0; i < arraysize(serialize_cases); i++) { | |
| 44 GURL input(serialize_cases[i]); | |
| 45 GURL output; | |
| 46 EXPECT_TRUE(proxy->Bounce(input, &output)); | |
| 47 | |
| 48 // We want to test each component individually to make sure its range was | |
| 49 // correctly serialized and deserialized, not just the spec. | |
| 50 EXPECT_EQ(input.possibly_invalid_spec(), output.possibly_invalid_spec()); | |
| 51 EXPECT_EQ(input.is_valid(), output.is_valid()); | |
| 52 EXPECT_EQ(input.scheme(), output.scheme()); | |
| 53 EXPECT_EQ(input.username(), output.username()); | |
| 54 EXPECT_EQ(input.password(), output.password()); | |
| 55 EXPECT_EQ(input.host(), output.host()); | |
| 56 EXPECT_EQ(input.port(), output.port()); | |
| 57 EXPECT_EQ(input.path(), output.path()); | |
| 58 EXPECT_EQ(input.query(), output.query()); | |
| 59 EXPECT_EQ(input.ref(), output.ref()); | |
| 60 } | |
| 61 | |
| 62 // Test an excessively long GURL. | |
| 63 { | |
| 64 const std::string url = std::string("http://example.org/").append( | |
| 65 mojo::kMaxUrlChars + 1, 'a'); | |
| 66 GURL input(url.c_str()); | |
| 67 GURL output; | |
| 68 EXPECT_TRUE(proxy->Bounce(input, &output)); | |
|
yzshen1
2016/03/03 21:47:56
Hmm.. this test case should result in message pipe
jam
2016/03/03 21:49:47
thanks for noticing that, yes that'd be great.
yzshen1
2016/03/09 00:01:52
I have looked into this issue and found that the s
| |
| 69 EXPECT_TRUE(output.is_empty()); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 } // namespace url | |
| OLD | NEW |