Commit be273689 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Fix OpenInController for multiple files

The |_documentController| wasn't reset between two files, leading to
an issue where it wasn't pointing to the correct file.

Fixed: 1062392
Change-Id: I5c4214c793c0e4e10f2c16af189c899683ba95b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2111092
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752002}
parent bf2f46ee
...@@ -438,12 +438,8 @@ class OpenInControllerBridge ...@@ -438,12 +438,8 @@ class OpenInControllerBridge
if (!_webState) if (!_webState)
return; return;
if (!_documentController) { _documentController =
// If this is called from a unit test, |documentController_| was set [UIDocumentInteractionController interactionControllerWithURL:fileURL];
// already.
_documentController =
[UIDocumentInteractionController interactionControllerWithURL:fileURL];
}
// TODO(cgrigoruta): The UTI is hardcoded for now, change this when we add // TODO(cgrigoruta): The UTI is hardcoded for now, change this when we add
// support for other file types as well. // support for other file types as well.
...@@ -699,11 +695,6 @@ class OpenInControllerBridge ...@@ -699,11 +695,6 @@ class OpenInControllerBridge
#pragma mark - TestingAditions #pragma mark - TestingAditions
- (void)setDocumentInteractionController:
(UIDocumentInteractionController*)controller {
_documentController = controller;
}
- (NSString*)suggestedFilename { - (NSString*)suggestedFilename {
return _suggestedFilename; return _suggestedFilename;
} }
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
@interface OpenInController (TestingAditions) @interface OpenInController (TestingAditions)
- (NSString*)suggestedFilename; - (NSString*)suggestedFilename;
- (void)startDownload; - (void)startDownload;
- (void)setDocumentInteractionController:
(UIDocumentInteractionController*)controller;
@end @end
#endif // IOS_CHROME_BROWSER_UI_OPEN_IN_OPEN_IN_CONTROLLER_TESTING_H_ #endif // IOS_CHROME_BROWSER_UI_OPEN_IN_OPEN_IN_CONTROLLER_TESTING_H_
...@@ -86,7 +86,9 @@ TEST_F(OpenInControllerTest, TestDisplayOpenInMenu) { ...@@ -86,7 +86,9 @@ TEST_F(OpenInControllerTest, TestDisplayOpenInMenu) {
histogram_tester_.ExpectTotalCount(kOpenInDownloadResultHistogram, 0); histogram_tester_.ExpectTotalCount(kOpenInDownloadResultHistogram, 0);
id document_controller = id document_controller =
[OCMockObject niceMockForClass:[UIDocumentInteractionController class]]; [OCMockObject niceMockForClass:[UIDocumentInteractionController class]];
[open_in_controller_ setDocumentInteractionController:document_controller]; id classMock = OCMClassMock([UIDocumentInteractionController class]);
OCMStub([classMock interactionControllerWithURL:[OCMArg any]])
.andReturn(document_controller);
[open_in_controller_ startDownload]; [open_in_controller_ startDownload];
[[[document_controller expect] andReturnValue:@YES] [[[document_controller expect] andReturnValue:@YES]
presentOpenInMenuFromRect:CGRectZero presentOpenInMenuFromRect:CGRectZero
...@@ -109,9 +111,12 @@ TEST_F(OpenInControllerTest, TestDisplayOpenInMenu) { ...@@ -109,9 +111,12 @@ TEST_F(OpenInControllerTest, TestDisplayOpenInMenu) {
TEST_F(OpenInControllerTest, TestCorruptedPDFDownload) { TEST_F(OpenInControllerTest, TestCorruptedPDFDownload) {
histogram_tester_.ExpectTotalCount(kOpenInDownloadResultHistogram, 0); histogram_tester_.ExpectTotalCount(kOpenInDownloadResultHistogram, 0);
id document_controller = id document_controller =
[OCMockObject niceMockForClass:[UIDocumentInteractionController class]]; [OCMockObject niceMockForClass:[UIDocumentInteractionController class]];
[open_in_controller_ setDocumentInteractionController:document_controller]; id classMock = OCMClassMock([UIDocumentInteractionController class]);
OCMStub([classMock interactionControllerWithURL:[OCMArg any]])
.andReturn(document_controller);
[open_in_controller_ startDownload]; [open_in_controller_ startDownload];
[[[document_controller reject] andReturnValue:@YES] [[[document_controller reject] andReturnValue:@YES]
presentOpenInMenuFromRect:CGRectZero presentOpenInMenuFromRect:CGRectZero
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment