Skip to content

Commit

Permalink
Change image.android to use the new image.Cache class from widgets. (#…
Browse files Browse the repository at this point in the history
…2832)

* Change image.android to use the new image.Cahce class from widgets.

* fix npm scripts

* npm tsc will compile all so no need for npm run dev-tsc-tests

* fix tslint error

* image-tests use memory only cache.

* fix exception in image.android

* Change image-tests so that Image won't be GC immediately.

* Change cacheMode to enum
  • Loading branch information
Hristo Hristov committed Oct 5, 2016
1 parent 3b99ed3 commit 98deecc
Show file tree
Hide file tree
Showing 14 changed files with 336 additions and 206 deletions.
151 changes: 68 additions & 83 deletions .vscode/launch.json
@@ -1,85 +1,70 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch on iOS Device",
"type": "nativescript",
"platform": "ios",
"request": "launch",
"appRoot": "${workspaceRoot}/tests",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false
},
{
"name": "Attach on iOS Device",
"type": "nativescript",
"platform": "ios",
"request": "attach",
"appRoot": "${workspaceRoot}/tests",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false
},
{
"name": "Launch on iOS Emulator",
"type": "nativescript",
"platform": "ios",
"request": "launch",
"appRoot": "${workspaceRoot}/tests",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": true
},
{
"name": "Attach on iOS Emulator",
"type": "nativescript",
"platform": "ios",
"request": "attach",
"appRoot": "${workspaceRoot}/tests",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": true
},
{
"name": "Launch on Android Device",
"type": "nativescript",
"platform": "android",
"request": "launch",
"appRoot": "${workspaceRoot}/tests",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false
},
{
"name": "Launch on Android Emulator",
"type": "nativescript",
"platform": "android",
"request": "launch",
"appRoot": "${workspaceRoot}/tests",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": true
},
{
"name": "Attach on Android Device",
"type": "nativescript",
"platform": "android",
"request": "attach",
"appRoot": "${workspaceRoot}/tests",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false
},
{
"name": "Attach on Android Emulator",
"type": "nativescript",
"platform": "android",
"request": "attach",
"appRoot": "${workspaceRoot}/tests",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": true
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Sync on iOS",
"type": "nativescript",
"platform": "ios",
"request": "launch",
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false,
"rebuild": false,
"syncAllFiles": false
},
{
"name": "Launch on iOS",
"type": "nativescript",
"platform": "ios",
"request": "launch",
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false,
"rebuild": true
},
{
"name": "Attach on iOS",
"type": "nativescript",
"platform": "ios",
"request": "attach",
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false
},
{
"name": "Sync on Android",
"type": "nativescript",
"platform": "android",
"request": "launch",
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false,
"rebuild": false
},
{
"name": "Launch on Android",
"type": "nativescript",
"platform": "android",
"request": "launch",
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false,
"rebuild": true
},
{
"name": "Attach on Android",
"type": "nativescript",
"platform": "android",
"request": "attach",
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"diagnosticLogging": false,
"emulator": false
}
]
}
1 change: 1 addition & 0 deletions apps/package.json
Expand Up @@ -16,6 +16,7 @@
"tns-core-modules": "2.1.0"
},
"devDependencies": {
"tns-platform-declarations": "*",
"babel-traverse": "6.10.4",
"babel-types": "6.11.1",
"babylon": "6.8.3",
Expand Down
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -36,17 +36,16 @@
"tsc": "tsc",
"tsc-w": "tsc --skipLibCheck -w",
"dev-tsc-tns-platform-declarations": "tsc -p tns-platform-declarations",
"dev-tsc-tns-core-modules": "tsc -p tns-core-modules",
"dev-tsc-tests": "tsc -p tests",
"dev-tsc-apps": "tsc -p apps",
"dev-tsc-all": "npm run dev-tsc-tns-platform-declarations && npm run dev-tsc-tns-core-modules && npm run dev-tsc-tests && npm run dev-tsc-apps",
"dev-tsc-all": "npm run dev-tsc-tns-platform-declarations && npm run tsc && npm run dev-tsc-tests && npm run dev-tsc-apps",
"dev-link-tns-platform-declarations": "cd tns-platform-declarations && npm link",
"dev-link-tns-core-modules": "cd tns-core-modules && npm link",
"dev-link-tests": "cd tests && npm link tns-platform-declarations && npm link tns-core-modules",
"dev-link-apps": "cd apps && npm link tns-platform-declarations && npm link tns-core-modules",
"dev-declarations": "npm run setup && rm -rf tns-platform-declarations/ios/objc* && TNS_TYPESCRIPT_DECLARATIONS_PATH=$PWD/tns-platform-declarations/ios/objc tns build ios --path tests",
"test": "npm run test-android && npm run test-ios",
"pretest": "npm run setup && npm run dev-tsc-tns-core-modules && npm run dev-tsc-tests",
"pretest": "npm run setup && npm run tsc",
"test-android": "tns run android --path tests --justlaunch",
"test-ios": "tns run ios --path tests --justlaunch",
"test-watch-android": "npm run pretest && concurrently --kill-others \"npm run tsc-tiw\" \"tns livesync android --path tests --watch\"",
Expand Down
10 changes: 10 additions & 0 deletions tests/.vscode/tasks.json
@@ -0,0 +1,10 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-p", "."],
"showOutput": "silent",
"problemMatcher": "$tsc"
}
8 changes: 4 additions & 4 deletions tests/app/TKUnit.ts
Expand Up @@ -214,19 +214,19 @@ export function assertNotEqual(actual: any, expected: any, message?: string) {
}
}

export function assertEqual(actual: any, expected: any, message?: string) {
export function assertEqual<T extends { equals?(arg: T): boolean }>(actual: T, expected: T, message?: string) {
if (!types.isNullOrUndefined(actual)
&& !types.isNullOrUndefined(expected)
&& types.getClass(actual) === types.getClass(expected)
&& types.isFunction(actual.equals)) {

// Use the equals method
if (!actual.equals(expected)) {
throw new Error(`${message} Actual: <${actual}>(${typeof(actual)}). Expected: <${expected}>(${typeof(expected)})`);
throw new Error(`${message} Actual: <${actual}>(${typeof (actual)}). Expected: <${expected}>(${typeof (expected)})`);
}
}
else if (actual !== expected) {
throw new Error(`${message} Actual: <${actual}>(${typeof(actual)}). Expected: <${expected}>(${typeof(expected)})`);
throw new Error(`${message} Actual: <${actual}>(${typeof (actual)}). Expected: <${expected}>(${typeof (expected)})`);
}
};

Expand Down Expand Up @@ -459,7 +459,7 @@ var doModalAndroid = function (quitLoop: () => boolean, timeoutSec: number) {
} else {
target.dispatchMessage(msg);
}

if (sdkVersion < 21) {//https://code.google.com/p/android-test-kit/issues/detail?id=84
msg.recycle();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/app/data/observable-tests.ts
Expand Up @@ -501,11 +501,11 @@ export function test_ObservableShouldEmitPropertyChangeWithSameObjectUsingWrappe
export function test_CorrectEventArgsWhenWrappedValueIsUsed() {
let testArray = [1];
let testObservable = new observable.Observable({ "property1": testArray});
let actualArgsValue = 0;
let actualArgsValue;
let propertyChangeHandler = function (args) {
actualArgsValue = args.value;

}

testObservable.on(observable.Observable.propertyChangeEvent, propertyChangeHandler);
testArray.push(2);

Expand Down

0 comments on commit 98deecc

Please sign in to comment.