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

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

Issue 2667803002: Picker takes a vector of pairs, and passes back the user chosen target. (Closed)
Patch Set: Dynamically enable/disable button Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/webshare/share_service_impl.cc ('k') | no next file » | 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
index 0e6eaf5657dc9ee0e68d4d11a0548bfc2096ea51..ad9140ab773eeb4fd1b2667935742ae80075a934 100644
--- a/chrome/browser/webshare/share_service_impl_unittest.cc
+++ b/chrome/browser/webshare/share_service_impl_unittest.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/run_loop.h"
+#include "base/strings/utf_string_conversions.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"
@@ -32,19 +33,20 @@ class ShareServiceTestImpl : public ShareServiceImpl {
return share_service_helper_raw;
}
- void set_picker_result(SharePickerResult result) {
+ void set_picker_result(base::Optional<std::string> result) {
picker_result_ = result;
}
const std::string& GetLastUsedTargetURL() { return last_used_target_url_; }
private:
- SharePickerResult picker_result_ = SharePickerResult::SHARE;
+ base::Optional<std::string> picker_result_;
std::string last_used_target_url_;
void ShowPickerDialog(
- const std::vector<base::string16>& targets,
- const base::Callback<void(SharePickerResult)>& callback) override {
+ const std::vector<std::pair<base::string16, GURL>>& targets,
+ const base::Callback<void(base::Optional<std::string>)>& callback)
+ override {
callback.Run(picker_result_);
}
@@ -92,6 +94,8 @@ TEST_F(ShareServiceImplUnittest, ShareCallbackParams) {
"https://wicg.github.io/web-share-target/demos/"
"sharetarget.html?title=My%20title&text=My%20text&url=https%3A%2F%2Fwww."
"google.com%2F";
+ share_service_helper_->set_picker_result(base::Optional<std::string>(
+ "https://wicg.github.io/web-share-target/demos/"));
const GURL url(kUrlSpec);
base::Callback<void(const base::Optional<std::string>&)> callback =
@@ -108,9 +112,8 @@ TEST_F(ShareServiceImplUnittest, ShareCallbackParams) {
// Tests the result of cancelling the share in the picker UI.
TEST_F(ShareServiceImplUnittest, ShareCancel) {
- // Ask that the dialog be cancelled.
- share_service_helper_->set_picker_result(SharePickerResult::CANCEL);
-
+ // picker_result_ is set to nullopt by default, so this imitates the user
+ // cancelling a share.
// Expect an error message in response.
base::Callback<void(const base::Optional<std::string>&)> callback =
base::Bind(&ShareServiceImplUnittest::DidShare, base::Unretained(this),
« no previous file with comments | « chrome/browser/webshare/share_service_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698