use of android.app.Activity in project PreLollipopTransition by takahirom.
the class MainActivityTest method testGoSubActivity2.
public void testGoSubActivity2() throws InterruptedException {
Spoon.screenshot(getActivity(), "init");
Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(SubActivity2.class.getName(), null, false);
final ImageView imageView = (ImageView) getActivity().findViewById(R.id.imageView2);
instrumentation.waitForIdleSync();
instrumentation.runOnMainSync(new Runnable() {
@Override
public void run() {
assertTrue(imageView.performClick());
}
});
Activity activity = instrumentation.waitForMonitor(monitor);
// Verify new activity was shown.
ANDROID.assertThat(monitor).hasHits(1);
// Wait for animation
Thread.sleep(2000l);
Spoon.screenshot(activity, "sub_activity_shown");
// subactivity -> mainactivity
sendKeys(KeyEvent.KEYCODE_BACK);
// Wait for animation
Thread.sleep(2000l);
instrumentation.waitForIdleSync();
Spoon.screenshot(getActivity(), "main_activity_backed");
}
use of android.app.Activity in project jpHolo by teusink.
the class StatusBar method execute.
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackContext The callback id used when calling back into JavaScript.
* @return True if the action was valid, false otherwise.
*/
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
Log.v(TAG, "Executing action: " + action);
final Activity activity = this.cordova.getActivity();
final Window window = activity.getWindow();
if ("_ready".equals(action)) {
boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
}
if ("show".equals(action)) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
});
return true;
}
if ("hide".equals(action)) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
});
return true;
}
return false;
}
use of android.app.Activity in project Rutgers-Course-Tracker by tevjef.
the class OrientationChangeAction method perform.
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
final Activity activity = (Activity) view.getContext();
activity.setRequestedOrientation(orientation);
Collection<Activity> resumedActivities = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED);
if (resumedActivities.isEmpty()) {
throw new RuntimeException("Could not change orientation");
}
}
use of android.app.Activity in project Shuttle by timusus.
the class ShuttleUtilsTest method testOpenShuttleLinkNullInput.
@Test
public void testOpenShuttleLinkNullInput() throws Exception {
Activity mockActivity = mock(Activity.class);
String fakePackage = "fake.package.name";
ShuttleUtils.openShuttleLink(null, null);
verify(mockActivity, never()).startActivity(any(Intent.class));
ShuttleUtils.openShuttleLink(mockActivity, null);
verify(mockActivity, never()).startActivity(any(Intent.class));
ShuttleUtils.openShuttleLink(null, fakePackage);
verify(mockActivity, never()).startActivity(any(Intent.class));
}
use of android.app.Activity in project Shuttle by timusus.
the class ShuttleUtilsTest method testOpenShuttleLinkMarketLink.
@Test
public void testOpenShuttleLinkMarketLink() throws Exception {
Activity mockActivity = mock(Activity.class);
String fakePackage = "fake.package.name";
// Call the method and capture the "fired" intent
ShuttleUtils.openShuttleLink(mockActivity, fakePackage);
ArgumentCaptor<Intent> intentCaptor = new ArgumentCaptor<>();
verify(mockActivity).startActivity(intentCaptor.capture());
Intent intent = intentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
// Also, I guess ShuttleUtils.isAmazonBuild() needs to be tested or we can't trust this test
if (ShuttleUtils.isAmazonBuild()) {
assertThat(intent.getData()).isEqualTo(Uri.parse("amzn://apps/android?p=" + fakePackage));
} else {
assertThat(intent.getData()).isEqualTo(Uri.parse("market://details?id=" + fakePackage));
}
}
Aggregations