-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdeviceReporterTests.js
More file actions
75 lines (58 loc) · 2.64 KB
/
deviceReporterTests.js
File metadata and controls
75 lines (58 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* GPII Android Device Reporter Tests
*
* Copyright 2013, 2014, 2015 Emergya
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* The research leading to these results has received funding from the European Union's
* Seventh Framework Programme (FP7/2007-2013)
* under grant agreement no. 289016.
*
* You may obtain a copy of the License at
* https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
var thatall = this;
(function () {
"use strict";
var fluid = require("universal"),
gpii = fluid.registerNamespace("gpii"),
jqUnit = fluid.require("jqUnit"),
bridge = require("bridge"),
androidDeviceReporter = bridge.load("net.gpii.AndroidDeviceReporterImpl",
thatall);
jqUnit.module("GPII Android deviceReporter");
jqUnit.test("Running tests for deviceReporter node module", function () {
// Check if all required methods are available through the java bridge
//
var methods = ["getJSONOutput"];
for (var method in methods) {
jqUnit.assertTrue("Checking availability of method '" + method + "'",
(methods[method] in androidDeviceReporter));
}
jqUnit.assertNotEquals("'getJSONOutput' does not return an empty object",
androidDeviceReporter.getJSONOutput(),
null);
// Check information that JSONOutput must contain
//
var deviceInfoCache = JSON.parse(androidDeviceReporter.getJSONOutput());
var fields = ["Device", "Model", "Manufacturer", "Product", "Brand",
"CPU", "rootAccess", "OS Version", "Build name",
"Kernel Version", "OS API Level", "Applications",
"Services"];
for (var field in fields) {
jqUnit.assertTrue("Checking availability of field '" + field + "'",
(fields[field] in deviceInfoCache));
}
// Check find methods
//
require("deviceReporter");
fluid.registerNamespace("gpii.androidDeviceReporter");
gpii.androidDeviceReporter.deviceInfoCache = deviceInfoCache;
jqUnit.assertNotEquals("Testing gpii.androidDeviceReporter.findApplication with a non-existent app name",
gpii.androidDeviceReporter.findApplication("should.not.exist"), true);
jqUnit.assertTrue("Testing gpii.androidDeviceReporter.findService",
gpii.androidDeviceReporter.findService("android"));
});
})();