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 "base/bind.h" | |
| 6 #include "base/callback.h" | |
| 7 #include "base/run_loop.h" | |
| 8 #include "chrome/browser/webshare/share_service_impl.h" | |
| 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | |
| 10 #include "mojo/public/cpp/bindings/interface_request.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 // Tests the Share Service mojo service defined in | |
| 15 // chrome/browser/webshare/share_service_impl.h | |
|
Matt Giuca
2016/12/08 06:42:56
No comment required here.
constantina
2016/12/09 02:24:15
Done.
| |
| 16 class ShareServiceTest : public ChromeRenderViewHostTestHarness { | |
| 17 public: | |
| 18 ShareServiceTest() {} | |
| 19 ~ShareServiceTest() override {} | |
| 20 | |
| 21 void SetUp() override { | |
| 22 ChromeRenderViewHostTestHarness::SetUp(); | |
|
Matt Giuca
2016/12/08 06:42:56
nit: Blank line after.
constantina
2016/12/09 02:24:14
Done.
| |
| 23 ShareServiceImpl::Create(mojo::GetProxy(&share_service_)); | |
| 24 } | |
| 25 | |
| 26 void callback(const base::Optional<std::string>& str) { | |
|
Matt Giuca
2016/12/08 06:42:56
Add an argument "const base::Optional<std::string>
constantina
2016/12/09 02:24:15
Done.
| |
| 27 EXPECT_EQ(base::Optional<std::string>("Not implemented: navigator.share"), | |
| 28 str); | |
| 29 | |
| 30 if (!quit_closure_.is_null()) | |
| 31 quit_closure_.Run(); | |
| 32 } | |
| 33 | |
| 34 blink::mojom::ShareServicePtr share_service_; | |
| 35 base::Closure quit_closure_; | |
| 36 }; | |
| 37 | |
| 38 // Basic test to check the Share method uses the callback as expected. | |
| 39 TEST_F(ShareServiceTest, ShareCallbackSuccess) { | |
| 40 LOG(ERROR) << "ShareCallbackSuccess entered"; | |
|
Matt Giuca
2016/12/08 06:42:56
Remove this debug log.
constantina
2016/12/09 02:24:14
Done.
| |
| 41 const GURL url("https://www.google.com"); | |
| 42 | |
| 43 base::RunLoop run_loop; | |
|
Matt Giuca
2016/12/08 06:42:56
Move this into SetUp (and make run_loop a class va
constantina
2016/12/09 02:24:14
Can't be done easily. In addition, run_loop can't
Matt Giuca
2016/12/09 02:32:21
Acknowledged.
| |
| 44 quit_closure_ = run_loop.QuitClosure(); | |
| 45 | |
| 46 base::Callback<void(const base::Optional<std::string>&)> cb = | |
|
Matt Giuca
2016/12/08 06:42:56
style: Don't abbreviate words in variable names (c
constantina
2016/12/09 02:24:14
Done.
| |
| 47 base::Bind(&ShareServiceTest::callback, base::Unretained(this)); | |
| 48 share_service_->Share("title", "text", url, cb); | |
| 49 | |
| 50 run_loop.Run(); | |
|
Matt Giuca
2016/12/08 06:42:56
You *might* be able to get away with putting this
constantina
2016/12/09 02:24:15
Acknowledged.
| |
| 51 } | |
| OLD | NEW |