Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions driver/lib/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,21 @@ class FlutterDriver extends BaseDriver<FluttertDriverConstraints> {
}

public async getOrientation(): Promise<string> {
return await this.proxydriver.getOrientation();
switch (_.toLower(this.internalCaps.platformName)) {
case PLATFORM.IOS:
return await this.proxydriver.proxyCommand('/orientation', 'GET');
default:
return await this.proxydriver.getOrientation();
}
}

public async setOrientation(orientation: string) {
return await this.proxydriver.setOrientation(orientation);
switch (_.toLower(this.internalCaps.platformName)) {
case PLATFORM.IOS:
return await this.proxydriver.proxyCommand('/orientation', 'POST', {orientation});
default:
return await this.proxydriver.setOrientation(orientation);
}
}

public validateLocatorStrategy(strategy: string) {
Expand Down Expand Up @@ -207,6 +217,11 @@ class FlutterDriver extends BaseDriver<FluttertDriverConstraints> {
} else if (cmd === `receiveAsyncResponse`) {
logger.debug(`Executing FlutterDriver response '${cmd}'`);
return await this.receiveAsyncResponse(...args);
} else if ([`setOrientation`, `getOrientation`].includes(cmd)) {
// should handle the command for ios and android differently
// in the flutter driver.
logger.debug(`Executing FlutterDriver command '${cmd}'`);
return await super.executeCommand(cmd, ...args);
} else {
if (this.driverShouldDoProxyCmd(cmd)) {
logger.debug(`Executing proxied driver command '${cmd}'`);
Expand Down
6 changes: 6 additions & 0 deletions example/ruby/example_sample2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def test_run_example_android
element = @driver.find_element :id, 'dev.flutter.example.androidfullscreen:id/launch_button'
element.click

@driver.orientation = :landscape
assert_equal @driver.orientation, :landscape
@driver.orientation = :portrait
assert_equal @driver.orientation, :portrait


@driver.context = 'FLUTTER'

text_finder = by_text 'Tap me!'
Expand Down
5 changes: 5 additions & 0 deletions example/ruby/example_sample2_ios.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def teardown
def test_run_example_ios
@driver.context = 'NATIVE_APP'

@driver.orientation = :landscape
assert_equal @driver.orientation, :landscape
@driver.orientation = :portrait
assert_equal @driver.orientation, :portrait

element = @driver.find_element :accessibility_id, 'launchFlutter'
element.click

Expand Down
Loading