Skip to content
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

Add rotation #143

Merged
merged 1 commit into from
Dec 10, 2012
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
4 changes: 4 additions & 0 deletions ruby-gem/lib/calabash-android/operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ def rotate(dir)
ni
end

def set_activity_orientation(orientation)
performAction('set_orientation', orientation)
end

def app_to_background(secs)
ni
end
Expand Down
1 change: 0 additions & 1 deletion ruby-gem/lib/calabash-android/steps/rotation_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
Then /^I rotate the device to portrait$/ do
rotate_phone(0)
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package sh.calaba.instrumentationbackend.actions.map;

import sh.calaba.instrumentationbackend.InstrumentationBackend;
import sh.calaba.instrumentationbackend.Result;
import sh.calaba.instrumentationbackend.actions.Action;

public class SetOrientation implements Action {

@Override
public Result execute(String... args) {
String orientation = "";
if (args != null && args.length >= 1) {
orientation = args[0].toLowerCase();
}

int changed = -1;

if( "landscape".contentEquals(orientation) ) {
changed = 0;
} else if( "portrait".contentEquals(orientation) ) {
changed = 1;
}

if (changed != -1) {
InstrumentationBackend.solo.setActivityOrientation(changed);
// Wait 100ms for orientation to happen.
try { Thread.sleep(100); } catch (Exception e) {}
// setActivityOrientation returns void so assume success.
return Result.successResult();
}

return new Result(false, "Requested invalid orientation: '" + orientation + "' Expected 'landscape' or 'portrait'.");
}

@Override
public String key() {
return "set_orientation";
}
}