diff --git a/AppFramework/Action/GREYActions.m b/AppFramework/Action/GREYActions.m index 9b24e1024..8fa46a1c6 100644 --- a/AppFramework/Action/GREYActions.m +++ b/AppFramework/Action/GREYActions.m @@ -573,24 +573,24 @@ + (void)initialize { } // Wait for keyboard to show up and any other UI changes to take effect. if (![GREYKeyboard waitForKeyboardToAppear]) { - NSString *description = - @"Keyboard did not appear after tapping on [Element]. " - @"Are you sure that tapping on this element will bring up the keyboard?"; __block NSString *elementDescription; grey_dispatch_sync_on_main_thread(^{ elementDescription = [element grey_description]; }); - NSDictionary *glossary = @{@"Element" : elementDescription}; - I_GREYPopulateErrorNoted(errorOrNil, kGREYInteractionErrorDomain, - kGREYInteractionActionFailedErrorCode, description, - glossary); + NSString *description + = [NSString stringWithFormat: + @"Keyboard did not appear after tapping on an element. " + @"\nAre you sure that tapping on this element will bring up the keyboard?" + @"\nElement: \n%@", element]; + I_GREYPopulateError(errorOrNil, kGREYInteractionErrorDomain, + kGREYInteractionActionFailedErrorCode, description); return NO; } } // If a position is given, move the text cursor to that position. __block id firstResponder = nil; - __block NSDictionary *errorGlossary = nil; + __block NSString *description = nil; grey_dispatch_sync_on_main_thread(^{ firstResponder = [[expectedFirstResponderView window] firstResponder]; if (position) { @@ -599,20 +599,18 @@ + (void)initialize { toPosition:position]; [firstResponder setSelectedTextRange:newRange]; } else { - errorGlossary = @{ - @"First Responder" : [firstResponder description], - @"Element" : [expectedFirstResponderView description] - }; + description + = [NSString stringWithFormat: + @"First Responder of Element does not conform to UITextInput protocol." + @"\nFirst Responder: %@ \nElement: %@", [firstResponder description], + [expectedFirstResponderView description]]; } } }); - if (errorGlossary) { - NSString *description = @"[First Responder] of [Element] does not conform to " - @"UITextInput protocol."; - I_GREYPopulateErrorNoted(errorOrNil, kGREYInteractionErrorDomain, - kGREYInteractionActionFailedErrorCode, description, - errorGlossary); + if (description) { + I_GREYPopulateError(errorOrNil, kGREYInteractionErrorDomain, + kGREYInteractionActionFailedErrorCode, description); return NO; } diff --git a/AppFramework/Action/GREYChangeStepperAction.m b/AppFramework/Action/GREYChangeStepperAction.m index e84f89b00..da7562e13 100644 --- a/AppFramework/Action/GREYChangeStepperAction.m +++ b/AppFramework/Action/GREYChangeStepperAction.m @@ -190,12 +190,11 @@ - (GREYStepperButtons *)grey_stepperButtonsForStepper:(UIStepper *)stepper }); if (!(foundMinusButton && foundPlusButton)) { - NSString *description = [NSString stringWithFormat:@"Failed to find stepper buttons " - @"in [Stepper]"]; - NSDictionary *glossary = @{@"[Stepper]" : [stepper description]}; - - I_GREYPopulateErrorNoted(error, kGREYInteractionErrorDomain, - kGREYInteractionActionFailedErrorCode, description, glossary); + NSString *description + = [NSString stringWithFormat:@"Failed to find stepper buttons in stepper:\n" + @"%@", [stepper description]]; + I_GREYPopulateError(error, kGREYInteractionErrorDomain, + kGREYInteractionActionFailedErrorCode, description); return nil; } return diff --git a/AppFramework/Action/GREYMultiFingerSwipeAction.m b/AppFramework/Action/GREYMultiFingerSwipeAction.m index faba317c3..5c9ba8208 100644 --- a/AppFramework/Action/GREYMultiFingerSwipeAction.m +++ b/AppFramework/Action/GREYMultiFingerSwipeAction.m @@ -107,11 +107,11 @@ - (BOOL)perform:(id)element error:(__strong NSError **)error { } else { NSString *errorDescription = [NSString stringWithFormat: - @"Cannot perform multi-finger swipe on view [V], as it has " - @"no window and it isn't a window itself."]; - I_GREYPopulateErrorNoted(error, kGREYSyntheticEventInjectionErrorDomain, - kGREYOrientationChangeFailedErrorCode, errorDescription, - @{@"V" : [element grey_description]}); + @"Cannot perform multi-finger swipe on the following view, as it has " + @"no window and it isn't a window itself:\n" + @"%@", [element grey_description]]; + I_GREYPopulateError(error, kGREYSyntheticEventInjectionErrorDomain, + kGREYOrientationChangeFailedErrorCode, errorDescription); return; } } diff --git a/AppFramework/Action/GREYPickerAction.m b/AppFramework/Action/GREYPickerAction.m index c97875f6d..38abad8f7 100644 --- a/AppFramework/Action/GREYPickerAction.m +++ b/AppFramework/Action/GREYPickerAction.m @@ -77,13 +77,11 @@ - (BOOL)grey_perform:(UIPickerView *)pickerView error:(__strong NSError **)error NSInteger componentCount = [dataSource numberOfComponentsInPickerView:pickerView]; if (componentCount < _column) { - NSString *description = [NSString stringWithFormat:@"Invalid column on [Picker] " - @"cannot find the column %lu.", - (unsigned long)_column]; - NSDictionary *glossary = @{@"Picker" : [pickerView description]}; - I_GREYPopulateErrorNoted(error, kGREYInteractionErrorDomain, - kGREYInteractionActionFailedErrorCode, description, glossary); - + NSMutableString *description = [NSMutableString stringWithFormat:@"Failed to Find Picker Column."]; + [description appendFormat:@"\n\nColumn: %lu", (unsigned long)_column]; + [description appendFormat:@"\n\nPicker: %@\n", [pickerView description]]; + I_GREYPopulateError(error, kGREYInteractionErrorDomain, + kGREYInteractionActionFailedErrorCode, description); return NO; } diff --git a/AppFramework/Action/GREYPinchAction.m b/AppFramework/Action/GREYPinchAction.m index 595037adc..cfc7b872b 100644 --- a/AppFramework/Action/GREYPinchAction.m +++ b/AppFramework/Action/GREYPinchAction.m @@ -91,12 +91,12 @@ - (BOOL)perform:(id)element error:(__strong NSError **)error { [viewToPinch isKindOfClass:[UIWindow class]] ? (UIWindow *)viewToPinch : viewToPinch.window; if (!window) { - NSString *errorDescription = [NSString stringWithFormat:@"Cannot pinch on [View], " + NSString *errorDescription = [NSString stringWithFormat:@"Cannot pinch on this view " @"as it has no window " - @"and it isn't a window itself."]; - NSDictionary *glossary = @{@"View" : element}; - I_GREYPopulateErrorNoted(error, kGREYPinchErrorDomain, kGREYPinchFailedErrorCode, - errorDescription, glossary); + @"and it isn't a window itself:" + @"\n%@", element]; + I_GREYPopulateError(error, kGREYPinchErrorDomain, + kGREYPinchFailedErrorCode, errorDescription); return; } @@ -117,29 +117,16 @@ - (NSArray *)calculateTouchPaths:(UIView *)view error:(__strong NSError **)error { CGRect pinchActionFrame = CGRectIntersection(view.accessibilityFrame, window.bounds); if (CGRectIsNull(pinchActionFrame)) { - NSMutableDictionary *errorDetails = [[NSMutableDictionary alloc] init]; - - errorDetails[kErrorDetailActionNameKey] = self.name; - errorDetails[kErrorDetailElementKey] = [view grey_description]; - errorDetails[kErrorDetailWindowKey] = window.description; - errorDetails[kErrorDetailRecoverySuggestionKey] = @"Make sure the element lies in the window"; - - NSArray *keyOrder = @[ - kErrorDetailActionNameKey, kErrorDetailElementKey, kErrorDetailWindowKey, - kErrorDetailRecoverySuggestionKey - ]; - - NSString *reasonDetail = [GREYObjectFormatter formatDictionary:errorDetails - indent:2 - hideEmpty:YES - keyOrder:keyOrder]; - + NSMutableString *errorDetails; + [errorDetails appendFormat:@"\n%@: %@", kErrorDetailActionNameKey, self.name]; + [errorDetails appendFormat:@"\n%@: %@", kErrorDetailElementKey, [view grey_description]]; + [errorDetails appendFormat:@"\n%@: %@", kErrorDetailWindowKey, window.description]; + [errorDetails appendFormat:@"\n%@: %@", kErrorDetailRecoverySuggestionKey, + @"Make sure the element lies in the window"]; NSString *reason = [NSString - stringWithFormat:@"Cannot apply pinch action on the element. Error: %@\n", reasonDetail]; - - I_GREYPopulateErrorNoted(error, kGREYPinchErrorDomain, kGREYPinchFailedErrorCode, reason, - @{@"V" : view}); - + stringWithFormat:@"Cannot apply pinch action on the element." + @"\nError Details: %@", errorDetails]; + I_GREYPopulateError(error, kGREYPinchErrorDomain, kGREYPinchFailedErrorCode, reason); return nil; } diff --git a/AppFramework/Action/GREYSwipeAction.m b/AppFramework/Action/GREYSwipeAction.m index 4abc5a627..a82e03122 100644 --- a/AppFramework/Action/GREYSwipeAction.m +++ b/AppFramework/Action/GREYSwipeAction.m @@ -99,14 +99,12 @@ - (BOOL)perform:(id)element error:(__strong NSError **)error { window = (UIWindow *)element; } else { NSString *errorDescription = - [NSString stringWithFormat:@"Cannot swipe on [View], as it has no window and " - @"it isn't a window itself."]; - NSDictionary *glossary = @{@"View" : [element grey_description]}; - GREYError *injectionError = - GREYErrorMakeWithHierarchy(kGREYSyntheticEventInjectionErrorDomain, - kGREYOrientationChangeFailedErrorCode, errorDescription); - injectionError.descriptionGlossary = glossary; - *error = injectionError; + [NSString stringWithFormat:@"Cannot swipe on this view as it has no window and " + @"isn't a window itself:" + @"\n%@", [element grey_description]]; + *error = GREYErrorMakeWithHierarchy(kGREYSyntheticEventInjectionErrorDomain, + kGREYOrientationChangeFailedErrorCode, + errorDescription); return; } } diff --git a/AppFramework/Action/GREYTapAction.m b/AppFramework/Action/GREYTapAction.m index 96dabb96b..dfd2d3a97 100644 --- a/AppFramework/Action/GREYTapAction.m +++ b/AppFramework/Action/GREYTapAction.m @@ -141,12 +141,10 @@ - (BOOL)perform:(id)element error:(__strong NSError **)error { }); if (!window) { NSString *description = - [NSString stringWithFormat:@"[Element] is not attached to a window."]; - NSDictionary *glossary = @{@"Element" : [element grey_description]}; - - I_GREYPopulateErrorNoted(error, kGREYInteractionErrorDomain, - kGREYInteractionActionFailedErrorCode, description, glossary); - + [NSString stringWithFormat:@"Element is not attached to a window:" + @"\n%@", [element grey_description]]; + I_GREYPopulateError(error, kGREYInteractionErrorDomain, + kGREYInteractionActionFailedErrorCode, description); return NO; } return [GREYTapper tapOnWindow:window diff --git a/AppFramework/Assertion/GREYAssertions.m b/AppFramework/Assertion/GREYAssertions.m index f3c4e02ec..90a092a4d 100644 --- a/AppFramework/Assertion/GREYAssertions.m +++ b/AppFramework/Assertion/GREYAssertions.m @@ -37,22 +37,15 @@ @implementation GREYAssertions GREYStringDescription *mismatch = [[GREYStringDescription alloc] init]; if (![matcher matches:element describingMismatchTo:mismatch]) { NSMutableString *reason = [[NSMutableString alloc] init]; - NSMutableDictionary *glossary = [[NSMutableDictionary alloc] init]; if (!element) { - [reason appendFormat:@"Assertion with [Matcher] failed: No UI element was matched."]; - glossary[@"Matcher"] = [matcher description]; - - I_GREYPopulateErrorNoted(errorOrNil, kGREYInteractionErrorDomain, - kGREYInteractionElementNotFoundErrorCode, reason, glossary); + [reason appendFormat:@"Assertion with Matcher failed: No UI element was matched.\n"]; + [reason appendFormat:@"Matcher: \n%@", [matcher description]]; + I_GREYPopulateError(errorOrNil, kGREYInteractionErrorDomain, + kGREYInteractionElementNotFoundErrorCode, reason); } else { - [reason appendFormat:@"Assertion with [Matcher] failed: UI [Element] failed to match " - @"the following matcher(s): [Mismatch]"]; - glossary[@"Matcher"] = [matcher description]; - glossary[@"Element"] = [element grey_description]; - glossary[@"Mismatch"] = [mismatch description]; - - I_GREYPopulateErrorNoted(errorOrNil, kGREYInteractionErrorDomain, - kGREYInteractionAssertionFailedErrorCode, reason, glossary); + [reason appendFormat:@"An assertion failed."]; + I_GREYPopulateError(errorOrNil, kGREYInteractionErrorDomain, + kGREYInteractionAssertionFailedErrorCode, reason); } return NO; } diff --git a/AppFramework/Core/GREYElementInteraction.m b/AppFramework/Core/GREYElementInteraction.m index 82f0cbf89..91cec9c37 100644 --- a/AppFramework/Core/GREYElementInteraction.m +++ b/AppFramework/Core/GREYElementInteraction.m @@ -824,7 +824,7 @@ - (NSError *)grey_errorToReturnForInteractionError:(GREYError *)interactionError if ([interactionError isKindOfClass:[GREYError class]]) { wrappedError = I_GREYErrorMake( interactionError.domain, interactionError.code, userInfo, interactionError.filePath, - interactionError.line, interactionError.functionName, interactionError.descriptionGlossary, + interactionError.line, interactionError.functionName, interactionError.stackTrace, hierarchy, appScreenshots); } else { // In case the error is an internal error from a custom matcher or assertion, just convert it diff --git a/AppFramework/Error/GREYAppError.h b/AppFramework/Error/GREYAppError.h index 22716c408..04b793e2e 100644 --- a/AppFramework/Error/GREYAppError.h +++ b/AppFramework/Error/GREYAppError.h @@ -36,7 +36,7 @@ #define GREYErrorMakeWithHierarchy(domain, code, description) \ I_GREYErrorMake((domain), (code), @{NSLocalizedDescriptionKey : (description)}, \ [NSString stringWithUTF8String:__FILE__], __LINE__, \ - [NSString stringWithUTF8String:__PRETTY_FUNCTION__], nil, \ + [NSString stringWithUTF8String:__PRETTY_FUNCTION__], \ [NSThread callStackSymbols], [GREYElementHierarchy hierarchyString], \ [GREYFailureScreenshotter screenshots]) @@ -62,7 +62,7 @@ (domain), (code), \ @{NSLocalizedDescriptionKey : (description), NSUnderlyingErrorKey : (nestedError)}, \ [NSString stringWithUTF8String:__FILE__], __LINE__, \ - [NSString stringWithUTF8String:__PRETTY_FUNCTION__], nil, [NSThread callStackSymbols], nil, \ + [NSString stringWithUTF8String:__PRETTY_FUNCTION__], [NSThread callStackSymbols], nil, \ nil) /** @@ -86,29 +86,6 @@ } \ }) -/** - * If @c errorRef is not @c NULL, it is set to a @c GREYError object that is created with - * the given @c domain, @c code, @c description and @c note. - * The description is accessible by querying error's @c userInfo with - * @c NSLocalizedDescriptionKey. - * - * @param[out] errorRef A @c GREYError reference for retrieving the created - * error object. - * @param domain The error domain. - * @param code The error code. - * @param description The error's localized description. - * @param glossary A glossary dictionary that is going to be populated with the error. - * - */ -#define I_GREYPopulateErrorNoted(errorRef, domain, code, description, glossary) \ - ({ \ - GREYError *e = GREYErrorMakeWithHierarchy((domain), (code), (description)); \ - e.descriptionGlossary = (glossary); \ - if (errorRef) { \ - *errorRef = e; \ - } \ - }) - /** * If @c errorRef is not @c NULL, it is set to a @c GREYError object that is created * with the given @c domain, @c code, @c description and @c nestedError. diff --git a/AppFramework/Synchronization/GREYUIThreadExecutor.m b/AppFramework/Synchronization/GREYUIThreadExecutor.m index 4b6212e72..f2586dbf8 100644 --- a/AppFramework/Synchronization/GREYUIThreadExecutor.m +++ b/AppFramework/Synchronization/GREYUIThreadExecutor.m @@ -29,6 +29,7 @@ #import "GREYDefines.h" #import "GREYLogger.h" #import "GREYStopwatch.h" +#import "GREYObjectFormatter.h" // Extern. NSString *const kGREYUIThreadExecutorErrorDomain = @@ -203,10 +204,16 @@ - (BOOL)executeSyncWithTimeout:(CFTimeInterval)seconds if (!isAppIdle) { NSOrderedSet *busyResources = [self grey_busyResources]; if ([busyResources count] > 0) { - NSString *description = @"Failed to execute block because idling resources are busy."; - I_GREYPopulateErrorNoted(error, kGREYUIThreadExecutorErrorDomain, - kGREYUIThreadExecutorTimeoutErrorCode, description, - [self grey_errorDictionaryForBusyResources:busyResources]); + NSDictionary *errorDictionary = [self grey_errorDictionaryForBusyResources:busyResources]; + NSString *busyResources = [GREYObjectFormatter formatDictionary:errorDictionary + indent:2 + hideEmpty:YES + keyOrder:errorDictionary.allKeys]; + NSString *description = [NSString stringWithFormat:@"Failed to execute block because idling resources are busy.\n%@", + busyResources]; + I_GREYPopulateError(error, kGREYUIThreadExecutorErrorDomain, + kGREYUIThreadExecutorTimeoutErrorCode, + description); } else { I_GREYPopulateError(error, kGREYUIThreadExecutorErrorDomain, kGREYUIThreadExecutorTimeoutErrorCode, diff --git a/CommonLib/Error/GREYError+Private.h b/CommonLib/Error/GREYError+Private.h index ddae1155b..56352a1a0 100644 --- a/CommonLib/Error/GREYError+Private.h +++ b/CommonLib/Error/GREYError+Private.h @@ -79,11 +79,6 @@ GREY_EXTERN NSString *const kErrorAppUIHierarchyKey; */ GREY_EXTERN NSString *const kErrorAppScreenShotsKey; -/** - * Key used to retrieve the description glossary from an error object dictionary. - */ -GREY_EXTERN NSString *const kErrorDescriptionGlossaryKey; - @interface GREYError (Private) @property(nonatomic) NSString *testCaseClassName; diff --git a/CommonLib/Error/GREYError.h b/CommonLib/Error/GREYError.h index 8d6b9bf94..cef8b15e0 100644 --- a/CommonLib/Error/GREYError.h +++ b/CommonLib/Error/GREYError.h @@ -35,7 +35,7 @@ #define GREYErrorMake(domain, code, description) \ I_GREYErrorMake((domain), (code), @{NSLocalizedDescriptionKey : (description)}, \ [NSString stringWithUTF8String:__FILE__], __LINE__, \ - [NSString stringWithUTF8String:__PRETTY_FUNCTION__], nil, \ + [NSString stringWithUTF8String:__PRETTY_FUNCTION__], \ [NSThread callStackSymbols], nil, nil) /** @@ -49,15 +49,14 @@ * @param filePath The file path where the error is generated. * @param line The file line where the error is generated. * @param functionName The function name where the error is generated. - * @param errorInfo A dictionary containing details about the error. * @param stackTrace The stack trace for the app when the error is generated. * * @return A @c GREYError object with the given input. */ GREY_EXTERN GREYError *I_GREYErrorMake(NSString *domain, NSInteger code, NSDictionary *userInfo, NSString *filePath, NSUInteger line, NSString *functionName, - NSDictionary *errorInfo, NSArray *stackTrace, - NSString *appUIHierarchy, NSDictionary *appScreenshots); + NSArray *stackTrace, NSString *appUIHierarchy, + NSDictionary *appScreenshots); /** * The string for a generic error in EarlGrey. @@ -178,11 +177,6 @@ GREY_EXTERN NSString *const kGREYScreenshotActualAfterImage; */ @property(nonatomic, readwrite) NSString *underlyingErrorDescription; -/** - * The error information dictionary that is associated with the error. - */ -@property(nonatomic, readonly) NSDictionary *errorInfo; - /** * The stack trace when the error is generated. */ @@ -203,11 +197,6 @@ GREY_EXTERN NSString *const kGREYScreenshotActualAfterImage; */ @property(nonatomic, readonly) GREYError *nestedError; -/** - * The description glossary dictionary that is associated with the error. - */ -@property(nonatomic) NSDictionary *descriptionGlossary; - /** * @remark init is not an available initializer. */ diff --git a/CommonLib/Error/GREYError.m b/CommonLib/Error/GREYError.m index f284ab96f..2f62f5564 100644 --- a/CommonLib/Error/GREYError.m +++ b/CommonLib/Error/GREYError.m @@ -43,7 +43,6 @@ NSString *const kErrorStackTraceKey = @"Stack Trace"; NSString *const kErrorAppUIHierarchyKey = @"App UI Hierarchy"; NSString *const kErrorAppScreenShotsKey = @"App Screenshots"; -NSString *const kErrorDescriptionGlossaryKey = @"Description Glossary"; NSString *const kGREYAppScreenshotAtFailure = @"App-side Screenshot at Point-of-Failure"; NSString *const kGREYTestScreenshotAtFailure = @"Test-side Screenshot at Failure"; @@ -71,14 +70,13 @@ @interface GREYError () GREYError *I_GREYErrorMake(NSString *domain, NSInteger code, NSDictionary *userInfo, NSString *filePath, NSUInteger line, NSString *functionName, - NSDictionary *errorInfo, NSArray *stackTrace, NSString *appUIHierarchy, + NSArray *stackTrace, NSString *appUIHierarchy, NSDictionary *appScreenshots) { GREYError *error = [[GREYError alloc] initWithDomain:domain code:code userInfo:userInfo]; error.filePath = filePath; error.line = line; error.functionName = functionName; - error.errorInfo = errorInfo; error.stackTrace = stackTrace; error.appUIHierarchy = appUIHierarchy; error.appScreenshots = appScreenshots; @@ -133,7 +131,6 @@ - (NSDictionary *)grey_descriptionDictionary { descriptionDictionary[kErrorStackTraceKey] = _stackTrace; descriptionDictionary[kErrorAppUIHierarchyKey] = _appUIHierarchy; descriptionDictionary[kErrorAppScreenShotsKey] = _appScreenshots; - descriptionDictionary[kErrorDescriptionGlossaryKey] = _descriptionGlossary; return descriptionDictionary; } @@ -174,7 +171,7 @@ + (NSString *)grey_nestedDescriptionForError:(NSError *)error { } NSArray *keyOrder = @[ - kErrorDescriptionKey, kErrorDescriptionGlossaryKey, kErrorDomainKey, kErrorCodeKey, + kErrorDescriptionKey, kErrorDomainKey, kErrorCodeKey, kErrorFileNameKey, kErrorFunctionNameKey, kErrorLineKey, kErrorTestCaseClassNameKey, kErrorTestCaseMethodNameKey ]; diff --git a/TestLib/EarlGreyImpl/EarlGrey.m b/TestLib/EarlGreyImpl/EarlGrey.m index 8c416dc94..7ed48e608 100644 --- a/TestLib/EarlGreyImpl/EarlGrey.m +++ b/TestLib/EarlGreyImpl/EarlGrey.m @@ -131,27 +131,14 @@ - (BOOL)rotateDeviceToOrientation:(UIDeviceOrientation)deviceOrientation error:( if (!success) { NSString *errorDescription; if (syncErrorBeforeRotation) { - NSString *errorReason = @"Application did not idle before rotating.\n%@\n%@"; - // TODO(b/147072566): Provide an error API to format description glossary on the test side. - NSString *descriptionGlossary = - [GREYObjectFormatter formatDictionary:syncErrorBeforeRotation.descriptionGlossary - indent:kGREYObjectFormatIndent - hideEmpty:YES - keyOrder:nil]; + NSString *errorReason = @"Application did not idle before rotating.\n%@"; errorDescription = - [NSString stringWithFormat:errorReason, syncErrorBeforeRotation.localizedDescription, - descriptionGlossary]; + [NSString stringWithFormat:errorReason, syncErrorBeforeRotation.localizedDescription]; } else if (syncErrorAfterRotation) { NSString *errorReason = - @"Application did not idle after rotating and before verifying the rotation.\n%@@\n%@"; - NSString *descriptionGlossary = - [GREYObjectFormatter formatDictionary:syncErrorBeforeRotation.descriptionGlossary - indent:kGREYObjectFormatIndent - hideEmpty:YES - keyOrder:nil]; + @"Application did not idle after rotating and before verifying the rotation.\n%@"; errorDescription = - [NSString stringWithFormat:errorReason, syncErrorAfterRotation.localizedDescription, - descriptionGlossary]; + [NSString stringWithFormat:errorReason, syncErrorAfterRotation.localizedDescription]; } else if (!syncErrorBeforeRotation && !syncErrorAfterRotation) { NSString *errorReason = @"Could not rotate application to orientation: %tu. XCUIDevice " @"Orientation: %tu UIDevice Orientation: %tu. UIDevice is the " diff --git a/TestLib/Exception/GREYFailureFormatter.m b/TestLib/Exception/GREYFailureFormatter.m index 205683411..bff9c5bde 100644 --- a/TestLib/Exception/GREYFailureFormatter.m +++ b/TestLib/Exception/GREYFailureFormatter.m @@ -58,12 +58,12 @@ + (NSString *)formatFailureForTestCase:(XCTestCase *)testCase GREYError *error = I_GREYErrorMake(kGREYGenericErrorDomain, kGREYGenericErrorCode, nil, filePath, lineNumber, - functionName, nil, stackTrace, hierarchy, appScreenshots); + functionName, stackTrace, hierarchy, appScreenshots); XCTestCase *currentTestCase = [XCTestCase grey_currentTestCase]; error.testCaseClassName = [currentTestCase grey_testClassName]; error.testCaseMethodName = [currentTestCase grey_testMethodName]; - NSArray *excluding = @[ kErrorFilePathKey, kErrorLineKey, kErrorDescriptionGlossaryKey ]; + NSArray *excluding = @[ kErrorFilePathKey, kErrorLineKey ]; return [self formatFailureForError:error excluding:excluding failureLabel:failureLabel @@ -155,17 +155,7 @@ + (NSString *)formatFailureForError:(GREYError *)error } } } - - if (![excluding containsObject:kErrorDescriptionGlossaryKey]) { - NSString *glossary = [GREYObjectFormatter formatDictionary:error.descriptionGlossary - indent:kGREYObjectFormatIndent - hideEmpty:YES - keyOrder:nil]; - NSString *glossaryString = - [NSString stringWithFormat:@"%@: %@\n", kErrorDescriptionGlossaryKey, glossary]; - [logger addObject:glossaryString]; - } - + return [logger componentsJoinedByString:@"\n"]; } diff --git a/Tests/Functional/HostDOCategories/GREYHostApplicationDistantObject+ErrorHandlingTest.h b/Tests/Functional/HostDOCategories/GREYHostApplicationDistantObject+ErrorHandlingTest.h index c629c8d42..631b61649 100644 --- a/Tests/Functional/HostDOCategories/GREYHostApplicationDistantObject+ErrorHandlingTest.h +++ b/Tests/Functional/HostDOCategories/GREYHostApplicationDistantObject+ErrorHandlingTest.h @@ -25,11 +25,6 @@ */ - (NSError *)errorPopulatedInTheApp; -/** - * @c returns A noted error populated by GREYError with the UI Hierarchy. - */ -- (NSError *)notedErrorPopulatedInTheApp; - /** * @c returns A simple error created with the UI Hierarchy. */ diff --git a/Tests/Functional/HostDOCategories/GREYHostApplicationDistantObject+ErrorHandlingTest.m b/Tests/Functional/HostDOCategories/GREYHostApplicationDistantObject+ErrorHandlingTest.m index 7600e8aa9..6b8eecb18 100644 --- a/Tests/Functional/HostDOCategories/GREYHostApplicationDistantObject+ErrorHandlingTest.m +++ b/Tests/Functional/HostDOCategories/GREYHostApplicationDistantObject+ErrorHandlingTest.m @@ -48,12 +48,6 @@ - (NSError *)errorPopulatedInTheApp { return error; } -- (NSError *)notedErrorPopulatedInTheApp { - NSError *error; - I_GREYPopulateErrorNoted(&error, kGREYGenericErrorDomain, kGREYGenericErrorCode, @"Foo", @{}); - return error; -} - - (NSError *)errorCreatedInTheApp { return GREYErrorMakeWithHierarchy(kGREYGenericErrorDomain, kGREYGenericErrorCode, @"Foo"); } diff --git a/Tests/Functional/Sources/ErrorHandlingTest.m b/Tests/Functional/Sources/ErrorHandlingTest.m index 733018891..c6d2ebb04 100644 --- a/Tests/Functional/Sources/ErrorHandlingTest.m +++ b/Tests/Functional/Sources/ErrorHandlingTest.m @@ -213,12 +213,6 @@ - (void)testErrorPopulatedInTheAppContainsOneHierarchy { (NSUInteger)1); } -- (void)testNestedErrorPopulatedInTheAppContainsOneHierarchy { - NSError *error = [[GREYHostApplicationDistantObject sharedInstance] notedErrorPopulatedInTheApp]; - XCTAssertEqual([self grey_hierarchyOccurrencesInErrorDescription:error.description], - (NSUInteger)1); -} - - (void)testErrorCreatedInTheAppContainsOneHierarchy { NSError *error = [[GREYHostApplicationDistantObject sharedInstance] errorPopulatedInTheApp]; XCTAssertEqual([self grey_hierarchyOccurrencesInErrorDescription:error.description], diff --git a/Tests/Functional/Sources/KeyboardKeysTest.m b/Tests/Functional/Sources/KeyboardKeysTest.m index 946b3b3e5..22b801ca6 100644 --- a/Tests/Functional/Sources/KeyboardKeysTest.m +++ b/Tests/Functional/Sources/KeyboardKeysTest.m @@ -146,7 +146,7 @@ - (void)testNonTypingTextField { GREYFail(@"Should throw an exception"); } @catch (NSException *exception) { NSRange exceptionRange = - [[exception reason] rangeOfString:@"Keyboard did not appear after tapping on [Element]"]; + [[exception reason] rangeOfString:@"Keyboard did not appear after tapping on an element."]; GREYAssertTrue(exceptionRange.length > 0, @"Should throw exception indicating keyboard did not appear."); } diff --git a/Tests/Functional/Sources/VisibilityTest.m b/Tests/Functional/Sources/VisibilityTest.m index 4466e7c6f..c03cc0aab 100644 --- a/Tests/Functional/Sources/VisibilityTest.m +++ b/Tests/Functional/Sources/VisibilityTest.m @@ -108,7 +108,7 @@ - (void)testInteractablityFailureDescription { [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"RedBar")] assertWithMatcher:grey_interactable() error:&error]; - XCTAssertTrue([error.description containsString:@"interactable Point:{nan, nan}"]); + XCTAssertTrue([error.description containsString:@"interactable Point:{0, 0}"]); } - (void)testVisibilityFailsWhenViewIsObscured {