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

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

Issue 2644793006: Add picker view for Web Share Target. (Closed)
Patch Set: Rebase. Created 3 years, 11 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 aba1777552e1fd0b1c3aa87d8fc192e86c0d43dc..0e6eaf5657dc9ee0e68d4d11a0548bfc2096ea51 100644
--- a/chrome/browser/webshare/share_service_impl_unittest.cc
+++ b/chrome/browser/webshare/share_service_impl_unittest.cc
@@ -32,11 +32,22 @@ class ShareServiceTestImpl : public ShareServiceImpl {
return share_service_helper_raw;
}
+ void set_picker_result(SharePickerResult result) {
+ picker_result_ = result;
+ }
+
const std::string& GetLastUsedTargetURL() { return last_used_target_url_; }
private:
+ SharePickerResult picker_result_ = SharePickerResult::SHARE;
std::string last_used_target_url_;
+ void ShowPickerDialog(
+ const std::vector<base::string16>& targets,
+ const base::Callback<void(SharePickerResult)>& callback) override {
+ callback.Run(picker_result_);
+ }
+
void OpenTargetURL(const GURL& target_url) override {
last_used_target_url_ = target_url.spec();
}
@@ -95,6 +106,26 @@ TEST_F(ShareServiceImplUnittest, ShareCallbackParams) {
run_loop.Run();
}
+// 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);
+
+ // Expect an error message in response.
+ base::Callback<void(const base::Optional<std::string>&)> callback =
+ base::Bind(&ShareServiceImplUnittest::DidShare, base::Unretained(this),
+ std::string(),
+ base::Optional<std::string>("Share was cancelled"));
+
+ base::RunLoop run_loop;
+ on_callback_ = run_loop.QuitClosure();
+
+ const GURL url(kUrlSpec);
+ share_service_->Share(kTitle, kText, url, callback);
+
+ run_loop.Run();
+}
+
// Replace various numbers of placeholders in various orders. Placeholders are
// adjacent to eachother; there are no padding characters.
TEST_F(ShareServiceImplUnittest, ReplacePlaceholders) {
« 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