This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Clipboard hasStrings method on iOS #19859
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
be1a37a
Implement Clipboard hasStrings method on iOS
justinmc 96ffe1e
Test call to hasStrings
justinmc 7018171
Formatting fixes
justinmc 6bab4c0
Move test to its own file
justinmc 555baec
Alphabetical order
justinmc 42ad924
Merge branch 'master' into has-strings
justinmc 2a8981a
Update licenses
justinmc e502d05
arguments nil instead of empty dictionary
justinmc 02970d6
Guarantee hasStrings will be true when tested
justinmc b7e1ddb
Formatting
justinmc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h" | ||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" | ||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h" | ||
#import "flutter/shell/platform/darwin/ios/platform_view_ios.h" | ||
#import "third_party/ocmock/Source/OCMock/OCMock.h" | ||
|
||
@interface FlutterPlatformPluginTest : XCTestCase | ||
@end | ||
|
||
@implementation FlutterPlatformPluginTest | ||
|
||
- (void)testHasStrings { | ||
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil]; | ||
std::unique_ptr<fml::WeakPtrFactory<FlutterEngine>> _weakFactory = | ||
std::make_unique<fml::WeakPtrFactory<FlutterEngine>>(engine); | ||
FlutterPlatformPlugin* plugin = | ||
[[FlutterPlatformPlugin alloc] initWithEngine:_weakFactory->GetWeakPtr()]; | ||
|
||
// Set some string to the pasteboard. | ||
__block bool calledSet = false; | ||
FlutterResult resultSet = ^(id result) { | ||
calledSet = true; | ||
}; | ||
FlutterMethodCall* methodCallSet = | ||
[FlutterMethodCall methodCallWithMethodName:@"Clipboard.setClipboardData" | ||
arguments:@{@"text" : @"some string"}]; | ||
[plugin handleMethodCall:methodCallSet result:resultSet]; | ||
XCTAssertEqual(calledSet, true); | ||
|
||
// Call hasStrings and expect it to be true. | ||
__block bool called = false; | ||
__block bool value; | ||
FlutterResult result = ^(id result) { | ||
called = true; | ||
value = result[@"value"]; | ||
}; | ||
FlutterMethodCall* methodCall = | ||
[FlutterMethodCall methodCallWithMethodName:@"Clipboard.hasStrings" arguments:nil]; | ||
[plugin handleMethodCall:methodCall result:result]; | ||
|
||
XCTAssertEqual(called, true); | ||
XCTAssertEqual(value, true); | ||
} | ||
|
||
@end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the
generalPasteboard
always guaranteed tohasStrings
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, I'm not sure. I'm going to add a call to setClipboardData right before to guarantee that it's true.