This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testRotateHomeScreen { | |
XCUIDevice *device = [XCUIDevice sharedDevice]; | |
[self verifyHomePageButtons]; | |
[device setOrientation:UIDeviceOrientationLandscapeRight]; | |
[self verifyHomePageButtons]; | |
[device setOrientation:UIDeviceOrientationPortraitUpsideDown]; | |
[self verifyHomePageButtons]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Compare two images. | |
* @param bitmap1 | |
* @param bitmap2 | |
* @return true iff both images have the same dimensions and pixel values. | |
*/ | |
public static boolean compareImages(Bitmap bitmap1, Bitmap bitmap2) { | |
if (bitmap1.getWidth() != bitmap2.getWidth() || | |
bitmap1.getHeight() != bitmap2.getHeight()) { | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A image from an array of colors. | |
* @param width | |
* @param height | |
* @param colors | |
* @return image of given width and height filled with the given color array. | |
*/ | |
public static Bitmap createImage(int width, int height, int[] colors) { | |
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); | |
int x = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A 3x3 2-color image. | |
* @param color1 | |
* @param color2 | |
* @return A 3x3 image alternating the two colors. | |
*/ | |
public static Bitmap createTwoColorImage(int color1, int color2) { | |
Bitmap bitmap = Bitmap.createBitmap(3, 3, Bitmap.Config.ARGB_8888); | |
bitmap.setPixel(0, 0, color1); | |
bitmap.setPixel(2, 0, color1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A one color image. | |
* @param width | |
* @param height | |
* @param color | |
* @return A one color image with the given width and height. | |
*/ | |
public static Bitmap createImage(int width, int height, int color) { | |
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); | |
Canvas canvas = new Canvas(bitmap); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)compareColorArrayRGBs:(NSArray *)array toExpected:(NSArray *)expected { | |
XCTAssertEqual([expected count], [array count]); | |
for (int i = 0; i < [expected count]; i++) { | |
UIColor *color = [array objectAtIndex:i]; | |
UIColor *expectedColor = [expected objectAtIndex:i]; | |
CGFloat r, g, b, a; | |
CGFloat eR, eG, eB, eA; | |
[color getRed:&r green:&g blue:&b alpha:&a]; | |
[expectedColor getRed:&eR green:&eG blue:&eB alpha:&eA]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an image from an array of colors. | |
+ (UIImage *)createImageWithPixelData:(NSArray *)pixelData width:(int)width height:(int)height { | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
// Add 1 for the alpha channel | |
size_t numberOfComponents = CGColorSpaceGetNumberOfComponents(colorSpace) + 1; | |
size_t bitsPerComponent = 8; | |
size_t bytesPerPixel = (bitsPerComponent * numberOfComponents) / 8; | |
size_t bytesPerRow = bytesPerPixel * width; | |
uint8_t *rawData = (uint8_t*)calloc([pixelData count] * numberOfComponents, sizeof(uint8_t)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Turn an image into an array of UIColors. | |
+ (NSArray *)pixelsForImage:(UIImage *)image { | |
NSUInteger width = [image size].width; | |
NSUInteger height = [image size].height; | |
NSUInteger count = width * height; | |
NSMutableArray *result = [NSMutableArray arrayWithCapacity:count]; | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
// Add 1 for the alpha channel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make an image all of one size, in whatever color. | |
+ (UIImage *)createTestImageWithWidth:(CGFloat)width | |
height:(CGFloat)height | |
color:(UIColor *)color { | |
CGRect rect = CGRectMake(0, 0, width, height); | |
UIGraphicsBeginImageContext(rect.size); | |
[color set]; | |
UIRectFill(rect); | |
UIImage *testImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <OCMock/OCMock.h> | |
#import <XCTest/XCTest.h> | |
#import "HomeView.h" | |
#import "HomeViewController.h" | |
#import "HomeViewPresenter.h" | |
#import "UIImageHelper.h" | |
@interface HomeViewPresenterTest : XCTestCase { | |
id mockCameraButton_; |