mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Release React Native for Android
This is an early release and there are several things that are known not to work if you're porting your iOS app to Android. See the Known Issues guide on the website. We will work with the community to reach platform parity with iOS.
This commit is contained in:
77
local-cli/__tests__/generator-android-test.js
Normal file
77
local-cli/__tests__/generator-android-test.js
Normal file
@@ -0,0 +1,77 @@
|
||||
'use strict';
|
||||
|
||||
jest.autoMockOff();
|
||||
|
||||
var path = require('path');
|
||||
|
||||
describe('react:android', function () {
|
||||
var assert = require('yeoman-generator').assert;
|
||||
|
||||
beforeEach(function (done) {
|
||||
var helpers = require('yeoman-generator').test;
|
||||
var generated = false;
|
||||
|
||||
runs(function() {
|
||||
helpers.run(path.resolve(__dirname, '..', 'generator-android'))
|
||||
.withArguments(['TestApp'])
|
||||
.withOptions({
|
||||
'package': 'com.reactnative.test',
|
||||
})
|
||||
.on('end', function() {
|
||||
generated = true;
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
jest.runAllTicks();
|
||||
jest.runOnlyPendingTimers();
|
||||
return generated;
|
||||
}, "generation", 750);
|
||||
});
|
||||
|
||||
it('creates files', function () {
|
||||
assert.file([
|
||||
path.join('android', 'build.gradle'),
|
||||
path.join('android', 'gradle.properties'),
|
||||
path.join('android', 'gradlew.bat'),
|
||||
path.join('android', 'gradlew'),
|
||||
path.join('android', 'settings.gradle'),
|
||||
path.join('android', 'app', 'build.gradle'),
|
||||
path.join('android', 'app', 'proguard-rules.pro'),
|
||||
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
|
||||
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
|
||||
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-hdpi', 'ic_launcher.png'),
|
||||
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-mdpi', 'ic_launcher.png'),
|
||||
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-xhdpi', 'ic_launcher.png'),
|
||||
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-xxhdpi', 'ic_launcher.png'),
|
||||
path.join('android', 'app', 'src', 'main', 'res', 'values', 'strings.xml'),
|
||||
path.join('android', 'app', 'src', 'main', 'res', 'values', 'styles.xml'),
|
||||
path.join('android', 'gradle', 'wrapper', 'gradle-wrapper.jar'),
|
||||
path.join('android', 'gradle', 'wrapper', 'gradle-wrapper.properties')
|
||||
]);
|
||||
});
|
||||
|
||||
it('replaces variables', function() {
|
||||
assert.fileContent(path.join('android', 'app', 'build.gradle'), 'applicationId "com.reactnative.test"');
|
||||
assert.fileContent(
|
||||
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
|
||||
'package="com.reactnative.test"'
|
||||
);
|
||||
assert.fileContent(
|
||||
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
|
||||
'name=".MainActivity"'
|
||||
);
|
||||
assert.fileContent(
|
||||
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
|
||||
'package com.reactnative.test;'
|
||||
);
|
||||
assert.fileContent(
|
||||
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
|
||||
'mReactRootView.startReactApplication(mReactInstanceManager, "TestApp", null);'
|
||||
);
|
||||
assert.fileContent(
|
||||
path.join('android', 'app', 'src', 'main', 'res', 'values', 'strings.xml'),
|
||||
'<string name="app_name">TestApp</string>'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -39,7 +39,13 @@ describe('react:react', function() {
|
||||
});
|
||||
|
||||
it('creates files', function() {
|
||||
assert.file(['.flowconfig', '.gitignore', '.watchmanconfig', 'index.ios.js']);
|
||||
assert.file([
|
||||
'.flowconfig',
|
||||
'.gitignore',
|
||||
'.watchmanconfig',
|
||||
'index.ios.js',
|
||||
'index.android.js'
|
||||
]);
|
||||
});
|
||||
|
||||
it('replaces vars in index.ios.js', function() {
|
||||
@@ -52,9 +58,25 @@ describe('react:react', function() {
|
||||
assert.noFileContent('index.ios.js', 'SampleApp');
|
||||
});
|
||||
|
||||
it('replaces vars in index.android.js', function() {
|
||||
assert.fileContent('index.android.js', 'var TestApp = React.createClass({');
|
||||
assert.fileContent(
|
||||
'index.android.js',
|
||||
'AppRegistry.registerComponent(\'TestApp\', () => TestApp);'
|
||||
);
|
||||
|
||||
assert.noFileContent('index.ios.js', 'SampleApp');
|
||||
});
|
||||
|
||||
it('composes with ios generator', function() {
|
||||
var stat = fs.statSync('ios');
|
||||
|
||||
expect(stat.isDirectory()).toBe(true);
|
||||
});
|
||||
|
||||
it('composes with android generator', function() {
|
||||
var stat = fs.statSync('android');
|
||||
|
||||
expect(stat.isDirectory()).toBe(true);
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user