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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/webshare/share_service_impl.h" | 8 #include "chrome/browser/webshare/share_service_impl.h" |
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 10 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 class ShareServiceTest : public ChromeRenderViewHostTestHarness { | 14 class ShareServiceTest : public ChromeRenderViewHostTestHarness { |
15 public: | 15 public: |
16 ShareServiceTest() = default; | 16 ShareServiceTest() = default; |
17 ~ShareServiceTest() override = default; | 17 ~ShareServiceTest() override = default; |
18 | 18 |
19 void SetUp() override { | 19 void SetUp() override { |
20 ChromeRenderViewHostTestHarness::SetUp(); | 20 ChromeRenderViewHostTestHarness::SetUp(); |
21 | 21 |
22 ShareServiceImpl::Create(mojo::GetProxy(&share_service_)); | 22 ShareServiceImpl::Create(mojo::MakeRequest(&share_service_)); |
23 } | 23 } |
24 | 24 |
25 void TearDown() override { | 25 void TearDown() override { |
26 ChromeRenderViewHostTestHarness::TearDown(); | 26 ChromeRenderViewHostTestHarness::TearDown(); |
27 } | 27 } |
28 | 28 |
29 void DidShare(const base::Optional<std::string>& expected, | 29 void DidShare(const base::Optional<std::string>& expected, |
30 const base::Optional<std::string>& str) { | 30 const base::Optional<std::string>& str) { |
31 EXPECT_EQ(expected, str); | 31 EXPECT_EQ(expected, str); |
32 | 32 |
(...skipping 14 matching lines...) Expand all Loading... |
47 on_callback_ = run_loop.QuitClosure(); | 47 on_callback_ = run_loop.QuitClosure(); |
48 | 48 |
49 base::Callback<void(const base::Optional<std::string>&)> callback = | 49 base::Callback<void(const base::Optional<std::string>&)> callback = |
50 base::Bind( | 50 base::Bind( |
51 &ShareServiceTest::DidShare, base::Unretained(this), | 51 &ShareServiceTest::DidShare, base::Unretained(this), |
52 base::Optional<std::string>("Not implemented: navigator.share")); | 52 base::Optional<std::string>("Not implemented: navigator.share")); |
53 share_service_->Share("title", "text", url, callback); | 53 share_service_->Share("title", "text", url, callback); |
54 | 54 |
55 run_loop.Run(); | 55 run_loop.Run(); |
56 } | 56 } |
OLD | NEW |