项目:Red-Calorie
文件:AddIngredientActivityTest.java
@Before
public void onSetUp() {
CaloriesCounterapplication applicationContext = (CaloriesCounterapplication) getTargetContext()
.getApplicationContext();
ApplicationTestComponent component = (ApplicationTestComponent) applicationContext.getComponent();
TagDao tagDao = component.getDaoSession().getTagDao();
tagDao.deleteall();
tagDao.insertInTx(exampleTags);
assertEquals(3,tagDao.loadAll().size());
main.launchActivity(new Intent(AddIngredientType.DRINK.getAction()));
// By default Espresso Intents does not stub any Intents. Stubbing needs to be setup before
// every test run. In this case all external Intents will be blocked.
intending(not(isInternal())).respondWith(new ActivityResult(Activity.RESULT_OK,null));
}
项目:Red-Calorie
文件:AddIngredientActivityTest.java
@Test
public void testSelectimageFromgallery() {
Intent intent = new Intent();
intent.setData(resourcetoUri(getContext(),android.R.drawable.ic_input_add));
intending(galleryIntentMatcher).respondWith(new ActivityResult(Activity.RESULT_OK,intent));
RxImageLoadingIdlingResource rxImageLoadingIdlingResource = RxImageLoadingIdlingResource.registerandGet();
onView(withId(R.id.image_header_image_view)).check(matches(isdisplayed()))
.perform(click());
PermissionHelper.allowPermissionsIfNeeded();
onView(withText(R.string.add_ingredient_image_select_from_camera))
.check(matches(isdisplayed()));
onView(withText(R.string.add_ingredient_image_select_title))
.check(matches(isdisplayed()));
onView(withText(R.string.add_ingredient_image_select_from_gallery))
.check(matches(isdisplayed()))
.perform(click());
intended(galleryIntentMatcher);
onView(withId(R.id.image_header_image_view))
.check(matches(isdisplayed()))
.check(matches(withDrawable(any(BitmapDrawable.class))));
rxImageLoadingIdlingResource.unregister();
}
项目:Red-Calorie
文件:AddIngredientActivityTest.java
@Test
public void testSelectimageFromCamera() throws Exception {
AddIngredientActivity activity = main.getActivity();
final Uri uri = resourcetoUri(activity,android.R.drawable.ic_input_add);
final Matcher<Intent> cameraIntentMatcher = allOf(
hasAction(MediaStore.ACTION_IMAGE_CAPTURE),injectUriOnMatch(activity,uri)
);
intending(cameraIntentMatcher).respondWith(new ActivityResult(Activity.RESULT_OK,null));
RxImageLoadingIdlingResource rxImageLoadingIdlingResource = RxImageLoadingIdlingResource.registerandGet();
onView(withId(R.id.image_header_image_view)).check(matches(isdisplayed()))
.perform(click());
PermissionHelper.allowPermissionsIfNeeded();
onView(withText(R.string.add_ingredient_image_select_from_camera))
.check(matches(isdisplayed()))
.perform(click());
intended(cameraIntentMatcher);
onView(withId(R.id.image_header_image_view))
.check(matches(isdisplayed()))
.check(matches(withDrawable(any(BitmapDrawable.class))));
rxImageLoadingIdlingResource.unregister();
}
项目:Red-Calorie
文件:AddMealActivityTest.java
@Test
public void testSelectimageFromgallery() {
onView(withId(R.id.add_meal_name)).perform(closeSoftKeyboard());
Intent intent = new Intent();
intent.setData(TestPicturePicker.resourcetoUri(getContext(),intent));
RxImageLoadingIdlingResource rxImageLoadingIdlingResource = RxImageLoadingIdlingResource.registerandGet();
onView(withId(R.id.image_header_image_view)).check(matches(isdisplayed()))
.perform(click());
PermissionHelper.allowPermissionsIfNeeded();
onView(withText(R.string.add_meal_image_select_from_camera))
.check(matches(isdisplayed()));
onView(withText(R.string.add_meal_image_select_title))
.check(matches(isdisplayed()));
onView(withText(R.string.add_meal_image_select_from_gallery))
.check(matches(isdisplayed()))
.perform(click());
intended(galleryIntentMatcher);
onView(withId(R.id.image_header_image_view))
.check(matches(isdisplayed()))
.check(matches(withDrawable(any(BitmapDrawable.class))));
rxImageLoadingIdlingResource.unregister();
}
项目:Red-Calorie
文件:AddMealActivityTest.java
@Test
public void testSelectimageFromCamera() {
onView(withId(R.id.add_meal_name)).perform(closeSoftKeyboard());
AddMealActivity activity = main.getActivity();
final Uri uri = TestPicturePicker.resourcetoUri(activity,uri)
);
intending(cameraIntentMatcher).respondWith(new ActivityResult(Activity.RESULT_OK,null));
RxImageLoadingIdlingResource rxImageLoadingIdlingResource = RxImageLoadingIdlingResource.registerandGet();
onView(withId(R.id.image_header_image_view)).check(matches(isdisplayed()))
.perform(click());
PermissionHelper.allowPermissionsIfNeeded();
onView(withText(R.string.add_meal_image_select_from_camera))
.check(matches(isdisplayed()))
.perform(click());
intended(cameraIntentMatcher);
onView(withId(R.id.image_header_image_view))
.check(matches(isdisplayed()))
.check(matches(withDrawable(any(BitmapDrawable.class))));
rxImageLoadingIdlingResource.unregister();
}
项目:FlightSearch
文件:SearchFlightsTest.java
@Test
public void testOriginResultOk() {
// Build a result to return when a particular AutocompleteActivity is launched.
Intent resultData = new Intent();
resultData.putExtra(AutocompleteActivity.AIRPORT_CODE_EXTRA,"DEN");
ActivityResult activityResult = new ActivityResult(Activity.RESULT_OK,resultData);
// Set up result stubbing when an intent sent to AutocompleteActivity is seen.
intending(hasComponent(AutocompleteActivity.class.getName())).respondWith(activityResult);
// Launching AutocompleteActivity expects airport code to be returned and displays it on the screen.
onView(withId(R.id.originTextView)).perform(click());
// test result
onView(withId(R.id.originTextView)).check(matches(withText("DEN")));
}
项目:FlightSearch
文件:SearchFlightsTest.java
@Test
public void testOriginResultCanceled() {
// Build a result to return when a particular AutocompleteActivity is launched.
Intent resultData = new Intent();
resultData.putExtra(AutocompleteActivity.AIRPORT_CODE_EXTRA,"DEN");
ActivityResult activityResult = new ActivityResult(Activity.RESULT_CANCELED,resultData);
// Set up result stubbing when an intent sent to AutocompleteActivity is seen.
intending(hasComponent(AutocompleteActivity.class.getName())).respondWith(activityResult);
// Launching AutocompleteActivity expects airport code to be returned and displays it on the screen.
onView(withId(R.id.originTextView)).perform(click());
// test result
onView(withId(R.id.originTextView)).check(matches(withText("")));
}
项目:FlightSearch
文件:SearchFlightsTest.java
@Test
public void testDestinationResultOK() {
// Build a result to return when a particular AutocompleteActivity is launched.
Intent resultData = new Intent();
resultData.putExtra(AutocompleteActivity.AIRPORT_CODE_EXTRA,"LAX");
ActivityResult activityResult = new ActivityResult(Activity.RESULT_OK,resultData);
// Set up result stubbing when an intent sent to AutocompleteActivity is seen.
intending(hasComponent(AutocompleteActivity.class.getName())).respondWith(activityResult);
// Launching AutocompleteActivity expects airport code to be returned and displays it on the screen.
onView(withId(R.id.destinationTextView)).perform(click());
// test result
onView(withId(R.id.destinationTextView)).check(matches(withText("LAX")));
}
项目:FlightSearch
文件:SearchFlightsTest.java
@Test
public void testDestinationResultCanceled() {
// Build a result to return when a particular AutocompleteActivity is launched.
Intent resultData = new Intent();
resultData.putExtra(AutocompleteActivity.AIRPORT_CODE_EXTRA,"LAX");
ActivityResult activityResult = new ActivityResult(Activity.RESULT_CANCELED,resultData);
// Set up result stubbing when an intent sent to AutocompleteActivity is seen.
intending(hasComponent(AutocompleteActivity.class.getName())).respondWith(activityResult);
// Launching AutocompleteActivity expects airport code to be returned and displays it on the screen.
onView(withId(R.id.destinationTextView)).perform(click());
// test result
onView(withId(R.id.destinationTextView)).check(matches(withText("")));
}
项目:friendspell
文件:MainActivityTest.java
@Test
public void signIn() {
setupGoogleapiclientBridge(googleapiclientBridge,false);
Activity activity = activityRule.launchActivity(null);
ActivityResult result = createSignInResult();
intending(hasAction("com.google.android.gms.auth.GOOGLE_SIGN_IN")).respondWith(result);
onView(withId(R.id.signed_out_pane))
.check(matches(isdisplayed()));
TestUtil.matchToolbarTitle(activity.getString(R.string.app_name));
onView(withId(R.id.sign_in_button))
.perform(click());
onView(withId(R.id.signed_out_pane))
.check(matches(not(isdisplayed())));
TestUtil.matchToolbarTitle(activity.getString(R.string.title_word_sets));
Mockito.verify(googleapiclientBridge,Mockito.times(2)).isSignedIn();
}
项目:androidtestdebug
文件:AddNoteScreenTest.java
@Test
public void addImagetoNote_ShowsThumbnailInUi() {
// Create an Activity Result which can be used to stub the camera Intent
ActivityResult result = createImageCaptureActivityResultStub();
// If there is an Intent with ACTION_IMAGE_CAPTURE,intercept the Intent and respond with
// a stubbed result.
intending(hasAction(MediaStore.ACTION_IMAGE_CAPTURE)).respondWith(result);
// Check thumbnail view is not displayed
onView(withId(R.id.add_note_image_thumbnail)).check(matches(not(isdisplayed())));
selectTakeImageFromMenu();
// Check that the stubbed thumbnail is displayed in the UI
onView(withId(R.id.add_note_image_thumbnail))
.perform(scrollTo()) // Scroll to thumbnail
.check(matches(allOf(
hasDrawable(),// Check ImageView has a drawable set with a custom matcher
isdisplayed())));
}
项目:Red-Calorie
文件:AddIngredientActivityTest.java
@Test
public void testSelectimageFromgalleryUserCanceled() {
intending(galleryIntentMatcher).respondWith(new ActivityResult(Activity.RESULT_CANCELED,null));
onView(withId(R.id.image_header_image_view)).check(matches(isdisplayed()))
.perform(click());
PermissionHelper.allowPermissionsIfNeeded();
onView(withText(R.string.add_ingredient_image_select_from_gallery))
.check(matches(isdisplayed()))
.perform(click());
intended(galleryIntentMatcher);
//If doesn't crash is good
}
项目:Red-Calorie
文件:AddIngredientActivityTest.java
@Test
public void testSelectimageFromCameraUserCanceled() {
final Matcher<Intent> cameraIntentMatcher = hasAction(MediaStore.ACTION_IMAGE_CAPTURE);
intending(cameraIntentMatcher).respondWith(new ActivityResult(Activity.RESULT_CANCELED,null));
onView(withId(R.id.image_header_image_view)).check(matches(isdisplayed()))
.perform(click());
PermissionHelper.allowPermissionsIfNeeded();
onView(withText(R.string.add_ingredient_image_select_from_camera))
.check(matches(isdisplayed()))
.perform(click());
intended(cameraIntentMatcher);
//If doesn't crash is good
}
项目:Red-Calorie
文件:AddIngredientActivityTest.java
@Test
public void testSearchIngredientOnTheInternet() throws Exception {
onView(withHint(R.string.add_ingredient_name_hint)).perform(typeTextIntoFocusedView("Eggs"));
closeSoftKeyboard();
onView(withId(R.id.add_ingredient_name_search)).perform(click());
Matcher<Intent> intentMatcher = allOf(hasAction(Intent.ACTION_VIEW),hasData("https://google.com/search?q=Eggs+calories"));
intending(intentMatcher).respondWith(new ActivityResult(Activity.RESULT_CANCELED,null));
intended(intentMatcher);
}
项目:Red-Calorie
文件:AddMealActivityTest.java
@Before
public void onSetUp() {
// By default Espresso Intents does not stub any Intents. Stubbing needs to be setup before
// every test run. In this case all external Intents will be blocked.
intending(not(isInternal())).respondWith(new ActivityResult(Activity.RESULT_OK,null));
ApplicationTestComponent component = (ApplicationTestComponent) ((CaloriesCounterapplication) getTargetContext().getApplicationContext()).getComponent();
DaoSession session = component.getDaoSession();
IngredientActivityTest.addExampleIngredientsTagsAndJoin(session);
session.getIngredientTemplateDao();
}
项目:Red-Calorie
文件:AddMealActivityTest.java
@Test
public void testSelectimageFromgalleryUserCanceled() {
intending(galleryIntentMatcher).respondWith(new ActivityResult(Activity.RESULT_CANCELED,null));
onView(withId(R.id.image_header_image_view)).check(matches(isdisplayed()))
.perform(click());
PermissionHelper.allowPermissionsIfNeeded();
onView(withText(R.string.add_meal_image_select_from_gallery))
.check(matches(isdisplayed()))
.perform(click());
intended(galleryIntentMatcher);
//If doesn't crash is good
}
项目:Red-Calorie
文件:AddMealActivityTest.java
@Test
public void testSelectimageFromCameraUserCanceled() {
onView(withId(R.id.add_meal_name)).perform(closeSoftKeyboard());
final Matcher<Intent> cameraIntentMatcher = hasAction(MediaStore.ACTION_IMAGE_CAPTURE);
intending(cameraIntentMatcher).respondWith(new ActivityResult(Activity.RESULT_CANCELED,null));
onView(withId(R.id.image_header_image_view)).check(matches(isdisplayed()))
.perform(click());
PermissionHelper.allowPermissionsIfNeeded();
onView(withText(R.string.add_meal_image_select_from_camera))
.check(matches(isdisplayed()))
.perform(click());
intended(cameraIntentMatcher);
//If doesn't crash is good
}
项目:ribot-app-android
文件:SignInActivityTest.java
private void stubAccountPickerIntent() {
// Stub the account picker using Espresso intents.
// It requires the test devices to be signed in into at least 1 Google account.
Intent data = new Intent();
data.putExtra(AccountManager.KEY_ACCOUNT_NAME,mSelectedAccount.name);
ActivityResult result = new ActivityResult(Activity.RESULT_OK,data);
// The account picker intent is a bit special and it doesn't seem to have an Action or
// package,so we have to match it by some of the extra keys.
// This is not ideal but I Couldn't find a better way.
intending(hasExtraWithKey("allowableAccountTypes"))
.respondWith(result);
}
项目:friendspell
文件:MainActivityTest.java
private ActivityResult createSignInResult() {
return new ActivityResult(Activity.RESULT_OK,null);
}
项目:AtlasForAndroid
文件:InstrumentationHook.java
public ActivityResult execStartActivity() {
return InstrumentationHook.this.mBase.execStartActivity(this.val$who,this.val$contextThread,this.val$token,this.val$target,this.val$intent,this.val$requestCode);
}
项目:AtlasForAndroid
文件:InstrumentationHook.java
public ActivityResult execStartActivity() {
return InstrumentationHook.this.mBase.execStartActivity(this.val$who,this.val$requestCode,this.val$options);
}
项目:AtlasForAndroid
文件:InstrumentationHook.java
public ActivityResult execStartActivity(Context context,IBinder iBinder,IBinder iBinder2,Activity activity,Intent intent,int i) {
return execStartActivityInternal(this.context,intent,new AnonymousClass_1(context,iBinder,iBinder2,activity,i));
}
项目:AtlasForAndroid
文件:InstrumentationHook.java
@TargetApi(16)
public ActivityResult execStartActivity(Context context,int i,Bundle bundle) {
return execStartActivityInternal(this.context,new AnonymousClass_2(context,i,bundle));
}
项目:AtlasForAndroid
文件:InstrumentationHook.java
@TargetApi(14)
public ActivityResult execStartActivity(Context context,Fragment fragment,new AnonymousClass_3(context,fragment,new AnonymousClass_4(context,bundle));
}
项目:AtlasForAndroid
文件:InstrumentationHook.java
private ActivityResult execStartActivityInternal(Context context,ExecStartActivityCallback execStartActivityCallback) {
String packageName;
Object className;
if (intent.getComponent() != null) {
packageName = intent.getComponent().getPackageName();
className = intent.getComponent().getClassName();
} else {
ResolveInfo resolveActivity = context.getPackageManager().resolveActivity(intent,0);
if (resolveActivity == null || resolveActivity.activityInfo == null) {
className = null;
packageName = null;
} else {
packageName = resolveActivity.activityInfo.packageName;
className = resolveActivity.activityInfo.name;
}
}
if (!StringUtils.equals(context.getPackageName(),packageName)) {
return execStartActivityCallback.execStartActivity();
}
if (DelegateComponent.locateComponent(className) != null) {
return execStartActivityCallback.execStartActivity();
}
try {
if (ClassLoadFromBundle.loadFromUninstalledBundles(className) != null) {
return execStartActivityCallback.execStartActivity();
}
} catch (ClassNotFoundException e) {
log.info("Can't find class " + className + " in all bundles.");
}
try {
if (Framework.getSystemClassLoader().loadClass(className) != null) {
return execStartActivityCallback.execStartActivity();
}
return null;
} catch (ClassNotFoundException e2) {
log.error("Can't find class " + className);
if (Framework.getClassNotFoundCallback() == null) {
return null;
}
if (intent.getComponent() == null && !TextUtils.isEmpty(className)) {
intent.setClassName(context,className);
}
if (intent.getComponent() == null) {
return null;
}
Framework.getClassNotFoundCallback().returnIntent(intent);
return null;
}
}
项目:AtlasForAndroid
文件:InstrumentationHook.java
public ActivityMonitor addMonitor(IntentFilter intentFilter,ActivityResult activityResult,boolean z) {
return this.mBase.addMonitor(intentFilter,activityResult,z);
}
项目:AtlasForAndroid
文件:InstrumentationHook.java
public ActivityMonitor addMonitor(String str,boolean z) {
return this.mBase.addMonitor(str,z);
}
项目:androidtestdebug
文件:AddNoteScreenTest.java
private ActivityResult createImageCaptureActivityResultStub() {
// Create the ActivityResult,with a null Intent since we do not want to return any data
// back to the Activity.
return new ActivityResult(Activity.RESULT_OK,null);
}
项目:android-test-kit
文件:IntentSpy.java
/**
* Returns the first matching stubbed result for the given activity if stubbed result was set by
* test author using the {@link #setActivityResultForIntent(Matcher,ActivityResult)} method. The
* method searches the list of existing matcher/response pairs in the order in which they were
* entered. If no stubbed result matching the given intent is found,a default RESULT_OK result
* with null data is returned.
*/
public ActivityResult getActivityResultForIntent(Intent intent);
项目:AtlasForAndroid
文件:InstrumentationHook.java
ActivityResult execStartActivity();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。