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

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

Issue 2644793006: Add picker view for Web Share Target. (Closed)
Patch Set: Fix unit tests and add cancellation test (adds virtual method to Impl class). 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
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..a53c8df86c9a63ac814d7dedead2577217a4a288 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(chrome::SharePickerResult result) {
+ picker_result_ = result;
+ }
+
const std::string& GetLastUsedTargetURL() { return last_used_target_url_; }
private:
+ chrome::SharePickerResult picker_result_ = chrome::SharePickerResult::SHARE;
std::string last_used_target_url_;
+ void ShowPickerDialog(const std::vector<base::string16>& targets,
+ const base::Callback<void(chrome::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(chrome::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) {

Powered by Google App Engine
This is Rietveld 408576698