diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/blue_square.imageset/Contents.json b/Examples/UIExplorer/UIExplorer/Images.xcassets/blue_square.imageset/Contents.json new file mode 100644 index 000000000..5de78da51 --- /dev/null +++ b/Examples/UIExplorer/UIExplorer/Images.xcassets/blue_square.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "blue_square.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/blue_square.imageset/blue_square.png b/Examples/UIExplorer/UIExplorer/Images.xcassets/blue_square.imageset/blue_square.png new file mode 100644 index 000000000..4974e084c Binary files /dev/null and b/Examples/UIExplorer/UIExplorer/Images.xcassets/blue_square.imageset/blue_square.png differ diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/red_square.imageset/Contents.json b/Examples/UIExplorer/UIExplorer/Images.xcassets/red_square.imageset/Contents.json new file mode 100644 index 000000000..808156987 --- /dev/null +++ b/Examples/UIExplorer/UIExplorer/Images.xcassets/red_square.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "red_square.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/red_square.imageset/red_square.png b/Examples/UIExplorer/UIExplorer/Images.xcassets/red_square.imageset/red_square.png new file mode 100644 index 000000000..0977a3e8c Binary files /dev/null and b/Examples/UIExplorer/UIExplorer/Images.xcassets/red_square.imageset/red_square.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp/testImageSnapshotTest_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp/testImageSnapshotTest_1@2x.png new file mode 100644 index 000000000..41492574c Binary files /dev/null and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerIntegrationTests-js-IntegrationTestsApp/testImageSnapshotTest_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerIntegrationTests.m b/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerIntegrationTests.m index f7b85ed3e..1bbd981ce 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerIntegrationTests.m +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerIntegrationTests.m @@ -63,6 +63,7 @@ RCT_TEST(IntegrationTestHarnessTest) RCT_TEST(TimersTest) RCT_TEST(AsyncStorageTest) RCT_TEST(AppEventsTest) +RCT_TEST(ImageSnapshotTest) RCT_TEST(SimpleSnapshotTest) // Disable due to flakiness: #8686784 diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/blue_square.png b/Examples/UIExplorer/UIExplorerIntegrationTests/blue_square.png new file mode 100644 index 000000000..4974e084c Binary files /dev/null and b/Examples/UIExplorer/UIExplorerIntegrationTests/blue_square.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/ImageSnapshotTest.js b/Examples/UIExplorer/UIExplorerIntegrationTests/js/ImageSnapshotTest.js new file mode 100644 index 000000000..13689742e --- /dev/null +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/js/ImageSnapshotTest.js @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + +var React = require('react-native'); +var { + Image, + View, +} = React; + +var { TestModule } = React.addons; + +var ImageSnapshotTest = React.createClass({ + componentDidMount() { + if (!TestModule.verifySnapshot) { + throw new Error('TestModule.verifySnapshot not defined.'); + } + }, + + done(success) { + TestModule.markTestPassed(success); + }, + + render() { + return ( + TestModule.verifySnapshot(this.done)} /> + ); + } +}); + +ImageSnapshotTest.displayName = 'ImageSnapshotTest'; + +module.exports = ImageSnapshotTest; diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js b/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js index ce9704f80..5ab306386 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js @@ -31,6 +31,7 @@ var TESTS = [ require('./LayoutEventsTest'), require('./AppEventsTest'), require('./SimpleSnapshotTest'), + require('./ImageSnapshotTest'), require('./PromiseTest'), ]; diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/red_square.png b/Examples/UIExplorer/UIExplorerIntegrationTests/red_square.png new file mode 100644 index 000000000..0977a3e8c Binary files /dev/null and b/Examples/UIExplorer/UIExplorerIntegrationTests/red_square.png differ diff --git a/Libraries/Image/RCTImageView.m b/Libraries/Image/RCTImageView.m index 5926f6331..049eb36ac 100644 --- a/Libraries/Image/RCTImageView.m +++ b/Libraries/Image/RCTImageView.m @@ -210,7 +210,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) - (void)reactSetFrame:(CGRect)frame { [super reactSetFrame:frame]; - if (self.image == nil) { + + if (!self.image || self.image == _defaultImage) { _targetSize = frame.size; [self reloadImage]; } else if ([RCTImageView srcNeedsReload:_src]) { @@ -254,7 +255,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) [strongSelf clearImage]; } }); - } else if (!self.image && self.src) { + } else if (!self.image || self.image == _defaultImage) { [self reloadImage]; } }