use of org.mozilla.focus.fragment.ScreenCaptureDialogFragment in project Rocket by mozilla-tw.
the class CaptureRunnable method run.
@Override
public void run() {
BrowserFragment browserFragment = refBrowserFragment.get();
if (browserFragment == null) {
return;
}
if (browserFragment.capturePage(this)) {
// onCaptureComplete called
} else {
// Capture failed
ScreenCaptureDialogFragment screenCaptureDialogFragment = refScreenCaptureDialogFragment.get();
if (screenCaptureDialogFragment != null) {
screenCaptureDialogFragment.dismiss();
}
promptScreenshotResult(false);
}
}
use of org.mozilla.focus.fragment.ScreenCaptureDialogFragment in project Rocket by mozilla-tw.
the class MyShotScreenshot method screenshotMyShot.
@Test
public void screenshotMyShot() {
// Browsing a web page
onView(allOf(withId(R.id.home_fragment_fake_input), isDisplayed())).perform(click());
onView(allOf(withId(R.id.url_edit), isDisplayed())).perform(replaceText(TARGET_URL_SITE), pressImeActionButton());
IdlingRegistry.getInstance().register(sessionLoadedIdlingResource);
onView(allOf(withId(R.id.display_url), isDisplayed())).check(matches(withText(TARGET_URL_SITE)));
IdlingRegistry.getInstance().unregister(sessionLoadedIdlingResource);
MockUIUtils.showToast(activityTestRule.getActivity(), R.string.screenshot_failed);
AndroidTestUtils.toastContainsText(activityTestRule.getActivity(), R.string.screenshot_failed);
Screengrab.screenshot(ScreenshotNamingUtils.SCREENSHOT_FAILED_TO_CAPTURE);
SystemClock.sleep(MockUIUtils.SHORT_DELAY);
final ScreenCaptureDialogFragment capturingFragment = ScreenCaptureDialogFragment.newInstance();
capturingFragment.show(activityTestRule.getActivity().getBrowserFragment().getChildFragmentManager(), "capturingFragment");
SystemClock.sleep(MockUIUtils.SHORT_DELAY);
onView(withText(R.string.screenshot_illustration)).check(matches(isDisplayed()));
Screengrab.screenshot(ScreenshotNamingUtils.SCREENSHOT_CAPTURING);
capturingFragment.dismiss(false);
screenshotIdlingResource = new ScreenshotIdlingResource(activityTestRule.getActivity());
// Click screen capture button
new BottomBarRobot().clickBrowserBottomBarItem(R.id.bottom_bar_capture);
IdlingRegistry.getInstance().register(screenshotIdlingResource);
// Open browser menu
AndroidTestUtils.tapBrowserMenuButton();
IdlingRegistry.getInstance().unregister(screenshotIdlingResource);
// Click my shot and take a screenshot of panel and toast
onView(allOf(withId(R.id.menu_screenshots), isDisplayed())).perform(click());
Screengrab.screenshot(ScreenshotNamingUtils.SCREENSHOT_PANEL_AND_SAVED);
// Click the first item in my shots panel
// Since "index=0" in ScreenshotItemAdapter is always date label, the first screenshot item will start from "index=1".
onView(withId(R.id.screenshot_grid_recycler_view)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
// Check if screenshot is displayed
onView(withId(R.id.screenshot_viewer_image)).check(matches(isDisplayed()));
// Click the info button and take a screenshot
onView(withId(R.id.screenshot_viewer_btn_info)).perform(click());
Screengrab.screenshot(ScreenshotNamingUtils.SCREENSHOT_INFO);
onView(withText(R.string.action_ok)).inRoot(isDialog()).perform(click());
// Click the delete button and take a screenshot
onView(withId(R.id.screenshot_viewer_btn_delete)).perform(click());
onView(withText(R.string.browsing_history_menu_delete)).check(matches(isDisplayed()));
Screengrab.screenshot(ScreenshotNamingUtils.SCREENSHOT_DELETE);
// Click delete button and take a screenshot of toast
onView(allOf(withText(R.string.browsing_history_menu_delete), isDisplayed())).perform(click());
Screengrab.screenshot(ScreenshotNamingUtils.SCREENSHOT_DELETED);
onView(withId(R.id.screenshots)).check(matches(isDisplayed()));
}
use of org.mozilla.focus.fragment.ScreenCaptureDialogFragment in project Rocket by mozilla-tw.
the class CaptureRunnable method onPostExecute.
@Override
protected void onPostExecute(final String path) {
ScreenCaptureDialogFragment screenCaptureDialogFragment = refScreenCaptureDialogFragment.get();
if (screenCaptureDialogFragment == null) {
cancel(true);
return;
}
final boolean captureSuccess = !TextUtils.isEmpty(path);
if (captureSuccess) {
Settings.getInstance(refContext.get()).setHasUnreadMyShot(true);
}
promptScreenshotResult(captureSuccess);
if (TextUtils.isEmpty(path)) {
screenCaptureDialogFragment.dismiss();
} else {
screenCaptureDialogFragment.dismiss(!AppConstants.isUnderEspressoTest());
}
}
Aggregations