mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 11:17:04 +08:00
Added application module tests.
This commit is contained in:
14
BCL.csproj
14
BCL.csproj
@ -27,7 +27,7 @@
|
||||
<OutputPath>bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'iOS'">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Android'">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
@ -129,6 +129,13 @@
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="image-source\index.ts" />
|
||||
<TypeScriptCompile Include="location\location.d.ts" />
|
||||
<TypeScriptCompile Include="Tests\application-tests-common.ts" />
|
||||
<TypeScriptCompile Include="Tests\application-tests.ios.ts">
|
||||
<DependentUpon>application-tests-common.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="Tests\application-tests.android.ts">
|
||||
<DependentUpon>application-tests-common.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="Tests\file-system-tests.ts" />
|
||||
<TypeScriptCompile Include="Tests\http-tests.ts" />
|
||||
<TypeScriptCompile Include="Tests\image-tests.ts" />
|
||||
@ -182,7 +189,6 @@
|
||||
<TypeScriptCompile Include="http\http.ios.ts">
|
||||
<DependentUpon>http.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
|
||||
<TypeScriptCompile Include="http\http.d.ts" />
|
||||
<TypeScriptCompile Include="local-settings\index.ts" />
|
||||
<TypeScriptCompile Include="local-settings\local-settings.d.ts" />
|
||||
@ -318,9 +324,7 @@
|
||||
</PropertyGroup>
|
||||
<UsingTask TaskName="BuildTasks.CopyForPlatformBuildTask" AssemblyFile="../../Build/lib/BuildTasks.dll" />
|
||||
<Target Name="AfterBuild">
|
||||
<CopyForPlatformBuildTask TargetPlatform="$(TargetOS)" IncludeTests="$(CopyTests)" Platforms="iOS;Android"
|
||||
InputFiles="@(GeneratedJavascript)" DestinationFolder="$(OutputPath)\$(Configuration)\"
|
||||
JSConfigFile="$(JSConfig)" AppMainJSFile="$(JSMainFile)" ProjectDir="$(ProjectDir)"/>
|
||||
<CopyForPlatformBuildTask TargetPlatform="$(TargetOS)" IncludeTests="$(CopyTests)" Platforms="iOS;Android" InputFiles="@(GeneratedJavascript)" DestinationFolder="$(OutputPath)\$(Configuration)\" JSConfigFile="$(JSConfig)" AppMainJSFile="$(JSMainFile)" ProjectDir="$(ProjectDir)" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
15
Tests/application-tests-common.ts
Normal file
15
Tests/application-tests-common.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import app = require("application/application");
|
||||
import TKUnit = require("Tests/TKUnit");
|
||||
|
||||
export var testInitDefined = function () {
|
||||
TKUnit.assert(app.init, "init function not defined.");
|
||||
}
|
||||
|
||||
export var testInitialized = function () {
|
||||
if (android) {
|
||||
// we have the android defined
|
||||
TKUnit.assert(app.android, "Application module not properly intialized");
|
||||
} else if (Foundation) {
|
||||
TKUnit.assert(app.ios, "Application module not properly intialized");
|
||||
}
|
||||
}
|
16
Tests/application-tests.android.ts
Normal file
16
Tests/application-tests.android.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import app = require("application/application");
|
||||
import TKUnit = require("Tests/TKUnit");
|
||||
import commonTests = require("Tests/application-tests-common");
|
||||
|
||||
// merge the exports of the application_common file with the exports of this file
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(commonTests, exports);
|
||||
|
||||
export var testAndroidApplicationInitialized = function () {
|
||||
TKUnit.assert(app.android, "Android application not initialized.");
|
||||
TKUnit.assert(app.android.context, "Android context not initialized.");
|
||||
TKUnit.assert(app.android.currentActivity, "Android currentActivity not initialized.");
|
||||
TKUnit.assert(app.android.startActivity, "Android mainActivity not initialized.");
|
||||
TKUnit.assert(app.android.nativeApp, "Android nativeApp not initialized.");
|
||||
TKUnit.assert(app.android.packageName, "Android packageName not initialized.");
|
||||
}
|
1
Tests/application-tests.ios.ts
Normal file
1
Tests/application-tests.ios.ts
Normal file
@ -0,0 +1 @@
|
||||
|
@ -65,7 +65,8 @@ export var testNativeFields = function () {
|
||||
|
||||
var getTestImageName = function (): string {
|
||||
if (app.ios) {
|
||||
return "AppIcon";
|
||||
// TODO: This expects
|
||||
return "logo";
|
||||
}
|
||||
if (app.android) {
|
||||
return "ic_launcher";
|
||||
|
@ -1,6 +1,7 @@
|
||||
var TKUnit = require("Tests/TKUnit");
|
||||
|
||||
var allTests = {};
|
||||
allTests["APPLICATION"] = require("Tests/application-tests");
|
||||
allTests["FILE SYSTEM"] = require("Tests/file-system-tests");
|
||||
allTests["HTTP"] = require("Tests/http-tests");
|
||||
allTests["LOCATION"] = require("Tests/location-tests");
|
||||
|
7
application/application.d.ts
vendored
7
application/application.d.ts
vendored
@ -60,7 +60,7 @@ export declare class AndroidApplication {
|
||||
/**
|
||||
* The main (start) Activity for the application.
|
||||
*/
|
||||
public mainActivity: android.app.Activity;
|
||||
public startActivity: android.app.Activity;
|
||||
|
||||
/**
|
||||
* The name of the application package.
|
||||
@ -117,6 +117,11 @@ export declare class iOSApplication {
|
||||
* The root view controller for the application.
|
||||
*/
|
||||
public rootController: UIKit.UIViewController;
|
||||
|
||||
/**
|
||||
* The android.app.Application object instance provided to the init of the module.
|
||||
*/
|
||||
public nativeApp: UIKit.UIApplication;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user