-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Bugfix FXIOS-13855 [Share Manager] Add remoteURL capability to .file share types for the Send to Device activity #30194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0f18c4f
5cac52c
52cdc33
ad616f4
b0bed70
c061103
914ee99
f85003b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| APP_VERSION = 145.0 | ||
| APP_VERSION = 145.1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,11 +32,37 @@ final class ShareManagerTests: XCTestCase { | |
|
|
||
| // MARK: - Test sharing a file | ||
|
|
||
| func testGetActivityItems_forFileURL_withNoShareText() throws { | ||
| func testGetActivityItems_forFileURL_withNoRemoteURL_withNoShareText() throws { | ||
| let testShareActivityType = UIActivity.ActivityType.message | ||
|
|
||
| let activityItems = ShareManager.getActivityItems( | ||
| forShareType: .file(url: testFileURL), | ||
| forShareType: .file(url: testFileURL, remoteURL: nil), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to add tests for when remoteURL != nil.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, I'll add this. Also, I'll look at adding some |
||
| withExplicitShareMessage: nil | ||
| ) | ||
|
|
||
| let urlActivityItemProvider = try XCTUnwrap(activityItems[safe: 0] as? URLActivityItemProvider) | ||
| let itemForURLActivity = urlActivityItemProvider.activityViewController( | ||
| createStubActivityViewController(), | ||
| itemForActivityType: testShareActivityType | ||
| ) | ||
|
|
||
| let telemetryActivityItemProvider = try XCTUnwrap(activityItems[safe: 1] as? ShareTelemetryActivityItemProvider) | ||
| let itemForShareActivity = telemetryActivityItemProvider.activityViewController( | ||
| createStubActivityViewController(), | ||
| itemForActivityType: testShareActivityType | ||
| ) | ||
|
|
||
| XCTAssertEqual(activityItems.count, 2) | ||
| XCTAssertEqual(itemForURLActivity as? URL, testFileURL) | ||
| XCTAssertTrue(itemForShareActivity is NSNull) | ||
| } | ||
|
|
||
| func testGetActivityItems_forFileURL_withRemoteURL_withNoShareText() throws { | ||
ih-codes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let testShareActivityType = UIActivity.ActivityType.message | ||
|
|
||
| // Should be no difference with or without remoteURL | ||
| let activityItems = ShareManager.getActivityItems( | ||
| forShareType: .file(url: testFileURL, remoteURL: testWebURL), | ||
| withExplicitShareMessage: nil | ||
| ) | ||
|
|
||
|
|
@@ -62,7 +88,7 @@ final class ShareManagerTests: XCTestCase { | |
| let testMessage = "Test message" | ||
| let testSubtitle = "Test subtitle" | ||
| let activityItems = ShareManager.getActivityItems( | ||
| forShareType: .file(url: testFileURL), | ||
| forShareType: .file(url: testFileURL, remoteURL: nil), | ||
| withExplicitShareMessage: ShareMessage(message: testMessage, subtitle: testSubtitle) | ||
| ) | ||
|
|
||
|
|
@@ -109,7 +135,7 @@ final class ShareManagerTests: XCTestCase { | |
| let testShareActivityType = UIActivity.ActivityType.message | ||
|
|
||
| let activityItems = ShareManager.getActivityItems( | ||
| forShareType: .file(url: testWebURL), | ||
| forShareType: .file(url: testWebURL, remoteURL: nil), | ||
| withExplicitShareMessage: nil | ||
| ) | ||
|
|
||
|
|
@@ -136,7 +162,7 @@ final class ShareManagerTests: XCTestCase { | |
| let testSubtitle = "Test subtitle" | ||
|
|
||
| let activityItems = ShareManager.getActivityItems( | ||
| forShareType: .file(url: testWebURL), | ||
| forShareType: .file(url: testWebURL, remoteURL: nil), | ||
| withExplicitShareMessage: ShareMessage(message: testMessage, subtitle: testSubtitle) | ||
| ) | ||
|
|
||
|
|
@@ -312,6 +338,59 @@ final class ShareManagerTests: XCTestCase { | |
| XCTAssertTrue(itemForShareActivity is NSNull) | ||
| } | ||
|
|
||
| // MARK: - Custom SendToDeviceActivity | ||
|
|
||
| func testCustomApplicationActivities_forSiteShare() throws { | ||
| let testShareActivityType = UIActivity.ActivityType("org.mozilla.ios.Fennec.sendToDevice") | ||
| let testActivityTitle = "Send Link to Device" | ||
|
|
||
| let testShareType = ShareType.site(url: testWebURL) | ||
|
|
||
| let activityItems = ShareManager.getApplicationActivities(forShareType: testShareType) | ||
|
|
||
| let customActivityType = try XCTUnwrap(activityItems[safe: 0] as? SendToDeviceActivity) | ||
| XCTAssertEqual(activityItems.count, 1) | ||
| XCTAssertEqual(customActivityType.activityTitle, testActivityTitle) | ||
| XCTAssertEqual(customActivityType.activityType, testShareActivityType) | ||
| } | ||
|
|
||
| func testCustomApplicationActivities_forTabShare() throws { | ||
| let testShareActivityType = UIActivity.ActivityType("org.mozilla.ios.Fennec.sendToDevice") | ||
| let testActivityTitle = "Send Link to Device" | ||
|
|
||
| let testShareType = ShareType.tab(url: testWebURL, tab: testTab) | ||
|
|
||
| let activityItems = ShareManager.getApplicationActivities(forShareType: testShareType) | ||
|
|
||
| let customActivityType = try XCTUnwrap(activityItems[safe: 0] as? SendToDeviceActivity) | ||
| XCTAssertEqual(activityItems.count, 1) | ||
| XCTAssertEqual(customActivityType.activityTitle, testActivityTitle) | ||
| XCTAssertEqual(customActivityType.activityType, testShareActivityType) | ||
| } | ||
|
|
||
| func testCustomApplicationActivities_forFileShareWithRemoteURL_AddsSendToDevice() throws { | ||
| let testShareActivityType = UIActivity.ActivityType("org.mozilla.ios.Fennec.sendToDevice") | ||
| let testActivityTitle = "Send Link to Device" | ||
|
|
||
| let testShareType = ShareType.file(url: testFileURL, remoteURL: testWebURL) | ||
|
|
||
| let activityItems = ShareManager.getApplicationActivities(forShareType: testShareType) | ||
|
|
||
| let customActivityType = try XCTUnwrap(activityItems[safe: 0] as? SendToDeviceActivity) | ||
| XCTAssertEqual(activityItems.count, 1) | ||
| XCTAssertEqual(customActivityType.activityTitle, testActivityTitle) | ||
| XCTAssertEqual(customActivityType.activityType, testShareActivityType) | ||
| } | ||
|
|
||
| func testCustomApplicationActivities_forFileShareWithNoRemoteURL_DoesNotAddSendToDevice() throws { | ||
| // Simulate file share for downloaded files | ||
| let testShareType = ShareType.file(url: testFileURL, remoteURL: nil) | ||
|
|
||
| let activityItems = ShareManager.getApplicationActivities(forShareType: testShareType) | ||
|
|
||
| XCTAssertEqual(activityItems.count, 0) | ||
| } | ||
|
|
||
| // MARK: - Helpers | ||
|
|
||
| private func createStubActivityViewController() -> UIActivityViewController { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.