Skip to content

Commit c946c24

Browse files
committed
Renamed image module to image-source. Extended the testRunner to accept module name to run.
1 parent 9a0fb96 commit c946c24

17 files changed

+75
-71
lines changed

BCL.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@
110110
</TypeScriptCompile>
111111
<TypeScriptCompile Include="file-system\file-system.d.ts" />
112112
<TypeScriptCompile Include="file-system\file-system-access.d.ts" />
113-
<TypeScriptCompile Include="image\image-native.android.ts">
114-
<DependentUpon>image-native.d.ts</DependentUpon>
113+
<TypeScriptCompile Include="image-source\image-source-native.android.ts">
114+
<DependentUpon>image-source-native.d.ts</DependentUpon>
115115
</TypeScriptCompile>
116-
<TypeScriptCompile Include="image\image-native.ios.ts">
117-
<DependentUpon>image-native.d.ts</DependentUpon>
116+
<TypeScriptCompile Include="image-source\image-source-native.ios.ts">
117+
<DependentUpon>image-source-native.d.ts</DependentUpon>
118118
</TypeScriptCompile>
119-
<TypeScriptCompile Include="image\image.ts">
120-
<DependentUpon>image.d.ts</DependentUpon>
119+
<TypeScriptCompile Include="image-source\image-source.d.ts" />
120+
<TypeScriptCompile Include="image-source\image-source-native.d.ts" />
121+
<TypeScriptCompile Include="image-source\image-source.ts">
122+
<DependentUpon>image-source.d.ts</DependentUpon>
121123
</TypeScriptCompile>
122-
<TypeScriptCompile Include="image\image.d.ts" />
123-
<TypeScriptCompile Include="image\image-native.d.ts" />
124-
<TypeScriptCompile Include="image\index.ts" />
124+
<TypeScriptCompile Include="image-source\index.ts" />
125125
<TypeScriptCompile Include="location\location.android.ts">
126126
<DependentUpon>location.d.ts</DependentUpon>
127127
</TypeScriptCompile>
@@ -188,7 +188,7 @@
188188
<DependentUpon>http-request.d.ts</DependentUpon>
189189
</TypeScriptCompile>
190190
<TypeScriptCompile Include="application\application-common.ts" />
191-
<Content Include="image\Readme.md" />
191+
<Content Include="image-source\Readme.md" />
192192
<TypeScriptCompile Include="local-settings\index.ts" />
193193
<TypeScriptCompile Include="local-settings\local-settings.d.ts" />
194194
<TypeScriptCompile Include="local-settings\local-settings.android.ts">

Tests/http-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export var test_getImage = function () {
121121
// </snippet>
122122

123123
TKUnit.waitUntilReady(isReady, 3);
124-
TKUnit.assert(result instanceof require("image").Image, "Result from getImage() should be valid Image object!");
124+
TKUnit.assert(result instanceof require("image-source").ImageSource, "Result from getImage() should be valid ImageSource object!");
125125
};
126126

127127
export var test_getImage_fail = function () {

Tests/image-tests.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import image = require("image/image");
1+
import imageSource = require("image-source/image-source");
22
import app = require("application/application");
33
import fs = require("file-system/file-system");
44
import TKUnit = require("Tests/TKUnit");
55

66
export var testFromResource = function () {
7-
var img = image.fromResource(getTestImageName());
7+
var img = imageSource.fromResource(getTestImageName());
88
TKUnit.assert(img.height > 0, "image.fromResource failed");
99
}
1010

1111
export var testFromUrl = function () {
1212
var completed;
13-
var result: image.Image;
13+
var result: imageSource.ImageSource;
1414

15-
image.fromUrl("http://www.google.com/images/errors/logo_sm_2.png")
16-
.then(function (res: image.Image) {
15+
imageSource.fromUrl("http://www.google.com/images/errors/logo_sm_2.png")
16+
.then(function (res: imageSource.ImageSource) {
1717
completed = true;
1818
result = res;
1919
})
@@ -31,11 +31,11 @@ export var testFromUrl = function () {
3131
}
3232

3333
export var testSaveToFile = function () {
34-
var img = image.fromResource(getTestImageName());
34+
var img = imageSource.fromResource(getTestImageName());
3535
var folder = fs.knownFolders.documents();
3636
var path = fs.path.join(folder.path, "Test.png");
3737

38-
var saved = img.saveToFile(path, image.ImageFormat.PNG);
38+
var saved = img.saveToFile(path, imageSource.ImageFormat.PNG);
3939
TKUnit.assert(saved, "Image not saved to file");
4040
TKUnit.assert(fs.File.exists(path), "Image not saved to file");
4141
}
@@ -44,7 +44,7 @@ export var testFromFile = function () {
4444
var folder = fs.knownFolders.documents();
4545
var path = fs.path.join(folder.path, "Test.png");
4646

47-
var img = image.fromFile(path);
47+
var img = imageSource.fromFile(path);
4848

4949
TKUnit.assert(img.height > 0, "image.fromResource failed");
5050

@@ -55,7 +55,7 @@ export var testFromFile = function () {
5555
}
5656

5757
export var testNativeFields = function () {
58-
var img = image.fromResource(getTestImageName());
58+
var img = imageSource.fromResource(getTestImageName());
5959
if (app.android) {
6060
TKUnit.assert(img.android != null, "Image.android not updated.");
6161
} else if (app.ios) {

Tests/testRunner.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
var TKUnit = require("Tests/TKUnit");
2-
var fsTests = require("Tests/file-system-tests");
3-
var httpTests = require("Tests/http-tests");
4-
var locationTests = require("Tests/location-tests");
5-
var localSettingsTests = require("Tests/local-settings-tests");
6-
var imageTests = require("Tests/image-tests");
72

8-
export var runAll = function () {
9-
TKUnit.runTestModule(imageTests, "IMAGE");
10-
TKUnit.runTestModule(fsTests, "FILE SYSTEM");
11-
TKUnit.runTestModule(httpTests, "HTTP");
12-
TKUnit.runTestModule(locationTests, "LOCATION");
13-
TKUnit.runTestModule(localSettingsTests, "LOCAL SETTINGS");
3+
var allTests = {};
4+
allTests["FILE SYSTEM"] = require("Tests/file-system-tests");
5+
allTests["HTTP"] = require("Tests/http-tests");
6+
allTests["LOCATION"] = require("Tests/location-tests");
7+
allTests["LOCAL SETTINGS"] = require("Tests/local-settings-tests");
8+
allTests["IMAGE SOURCE"] = require("Tests/image-tests");
9+
10+
export var runAll = function (moduleName?: string) {
11+
for (var name in allTests) {
12+
if(moduleName && (moduleName.toLowerCase() !== name.toLowerCase())) {
13+
continue;
14+
}
15+
16+
TKUnit.runTestModule(allTests[name], name);
17+
}
1418
}

file-system/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
declare var module, require;
2-
module.exports = require("file-system/file_system");
2+
module.exports = require("file-system/file-system");

http/http-request.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function request(options: http.HttpRequestOptions): promises.Promise<http
2525
raw: data,
2626
toString: () => { return null },
2727
toJSON: () => { return null },
28-
toImage: () => { return require("image").fromNativeBitmap(data); }
28+
toImage: () => { return require("image-source").fromNativeSource(data); }
2929
},
3030
statusCode: 0,
3131
headers: {}

http/http-request.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The http client interface.
33
*/
4-
import image_module = require("image/image");
4+
import image_module = require("image-source/image-source");
55
import promises = require("promises/promises");
66

77
export declare function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;
@@ -24,5 +24,5 @@ export interface HttpContent {
2424
raw: any;
2525
toString: () => string;
2626
toJSON: () => any;
27-
toImage: () => image_module.Image;
27+
toImage: () => image_module.ImageSource;
2828
}

http/http-request.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function request(options: http.HttpRequestOptions): promises.Promise<http
5454
raw: data,
5555
toString: () => { return NSDataToString(data); },
5656
toJSON: () => { return JSON.parse(NSDataToString(data)); },
57-
toImage: () => { return require("image").fromData(data); }
57+
toImage: () => { return require("image-source").fromData(data); }
5858
},
5959
statusCode: response.statusCode(),
6060
headers: headers

http/http.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import image_module = require("image/image");
1+
import image_module = require("image-source/image-source");
22
import promises = require("promises/promises");
33
import http = require("http/http-request");
44

@@ -37,8 +37,8 @@ export function getJSON<T>(url: string): promises.Promise<T> {
3737
/**
3838
* Gets image from url.
3939
*/
40-
export function getImage(url: string): promises.Promise<image_module.Image> {
41-
var d = promises.defer<image_module.Image>();
40+
export function getImage(url: string): promises.Promise<image_module.ImageSource> {
41+
var d = promises.defer<image_module.ImageSource>();
4242

4343
http.request({ url: url, method: "GET" })
4444
.then(r => d.resolve(r.content.toImage()))
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The way we get local path here is different for now. Maybe we should get it from FS module in the future samples. Sample code Android:
22

33
```
4-
var Image = require("image").Image;
5-
var baseImage = Image.imageFromResource('foxie');
4+
var ImageSource = require("image-source").ImageSource;
5+
var source = ImageSource.imageFromResource('foxie');
66
```

0 commit comments

Comments
 (0)