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

Unified Diff: chrome/browser/webshare/share_service_impl_unittest.cc

Issue 2545323002: Implemented stub ShareService mojo service, for navigator.share. (Closed)
Patch Set: Added 'expected' parameter to callback, as per feedback. Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/webshare/share_service_impl.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webshare/share_service_impl_unittest.cc
diff --git a/chrome/browser/webshare/share_service_impl_unittest.cc b/chrome/browser/webshare/share_service_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ca7f317ce7070906326765f0a8c98115bc0dd23b
--- /dev/null
+++ b/chrome/browser/webshare/share_service_impl_unittest.cc
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/run_loop.h"
+#include "chrome/browser/webshare/share_service_impl.h"
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
+
+class ShareServiceTest : public ChromeRenderViewHostTestHarness {
+ public:
+ ShareServiceTest() {}
+ ~ShareServiceTest() override {}
+
+ void SetUp() override {
+ ChromeRenderViewHostTestHarness::SetUp();
+
+ ShareServiceImpl::Create(mojo::GetProxy(&share_service_));
+ }
+
+ void callback(const base::Optional<std::string>& expected,
+ const base::Optional<std::string>& str) {
+ EXPECT_EQ(expected, str);
+
+ if (!quit_closure_.is_null())
Matt Giuca 2016/12/09 02:32:21 Maybe rename this to |on_callback_|, because this
constantina 2016/12/09 02:43:01 I like it. Done.
+ quit_closure_.Run();
+ }
+
+ blink::mojom::ShareServicePtr share_service_;
+ base::Closure quit_closure_;
+};
+
+// Basic test to check the Share method uses the callback as expected.
+TEST_F(ShareServiceTest, ShareCallbackSuccess) {
+ const GURL url("https://www.google.com");
+
+ base::RunLoop run_loop;
+ quit_closure_ = run_loop.QuitClosure();
+
+ base::Callback<void(const base::Optional<std::string>&)> callback =
+ base::Bind(
+ &ShareServiceTest::callback, base::Unretained(this),
+ base::Optional<std::string>("Not implemented: navigator.share"));
+ share_service_->Share("title", "text", url, callback);
+
+ run_loop.Run();
+}
« no previous file with comments | « chrome/browser/webshare/share_service_impl.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698