PageRenderTime 214ms CodeModel.GetById 143ms app.highlight 13ms RepoModel.GetById 56ms app.codeStats 0ms

/tests/automatic_tests/save_devtools_settings/mocha_test.js

https://github.com/zybjtu/node-webkit
JavaScript | 101 lines | 90 code | 8 blank | 3 comment | 7 complexity | 97f5cbdc5719cb4f6112108aa686f835 MD5 | raw file
  1var path = require('path');
  2var app_test = require('./nw_test_app');
  3var assert = require('assert');
  4var original;
  5var changed;
  6var ok = false;
  7
  8function read_changed(done) {
  9    if (!ok)
 10	setTimeout(read_changed, 2000, done);
 11    else {
 12	var child = app_test.createChildProcess({
 13	    execPath: process.execPath,
 14	    appPath: path.join(global.tests_dir, 'save_devtools_settings'),
 15	    args: [0],
 16	    end: function(data, app) {
 17		changed = data;
 18		app.kill();
 19		done();
 20		console.log("secnond");
 21	    }
 22	});
 23    }
 24}
 25
 26describe('save_devtools_settings', function() {
 27    
 28    before(function(done) {
 29	this.timeout(0);
 30	var child = app_test.createChildProcess({
 31	    execPath: process.execPath,
 32	    appPath: path.join(global.tests_dir, 'save_devtools_settings'),
 33	    args: [1],
 34	    end: function(data, app) {
 35		original = data;
 36		app.kill();
 37		ok = true;
 38		console.log("first");
 39	    }
 40	});
 41	setTimeout(read_changed, 2000, done);
 42    });
 43    
 44    it("should save devtools' settings", function() {
 45	var i = 0;
 46	// general
 47	assert.notEqual(original[i], changed[i]); i++;
 48	assert.notEqual(original[i], changed[i]); i++;
 49	assert.notEqual(original[i], changed[i]); i++;
 50	assert.notEqual(original[i], changed[i]); i++;
 51	assert.equal((original[i] + 1) % 4, changed[i]); i++;
 52	assert.notEqual(original[i], changed[i]); i++;
 53	assert.notEqual(original[i], changed[i]); i++;
 54	assert.notEqual(original[i], changed[i]); i++;
 55	assert.notEqual(original[i], changed[i]); i++;
 56	assert.notEqual(original[i], changed[i]); i++;
 57	assert.notEqual(original[i], changed[i]); i++;
 58	assert.notEqual(original[i], changed[i]); i++;
 59	assert.notEqual(original[i], changed[i]); i++;
 60
 61	assert.equal((original[i] + 1) % 4, changed[i]); i++;
 62	assert.notEqual(original[i], changed[i]); i++;
 63	assert.notEqual(original[i], changed[i]); i++;
 64	assert.notEqual(original[i], changed[i]); i++;
 65	if (!original[i - 1])
 66	    assert.equal((original[i] + 1) % 10, changed[i]);
 67	i++;
 68	assert.notEqual(original[i], changed[i]); i++;
 69	assert.notEqual(original[i], changed[i]); i++;
 70	assert.notEqual(original[i], changed[i]); i++;
 71	assert.notEqual(original[i], changed[i]); i++;
 72
 73	// overrides
 74	assert.notEqual(original[i], changed[i]); i++;
 75	if (!original[i - 1])
 76	    // 0~21                                                                                               
 77	    assert.equal((original[i] + 1) % 22, changed[i]);
 78	i++;
 79	assert.notEqual(original[i], changed[i]); i++;
 80	assert.notEqual(original[i], changed[i]); i++;
 81	assert.notEqual(original[i], changed[i]); i++;
 82	if (!original[i - 1]) {
 83	    assert.equal((original[i] + 1) % 10, changed[i]); i++;
 84	    assert.equal((original[i] + 1) % 10, changed[i]); i++;
 85	}
 86	assert.notEqual(original[i], changed[i]); i++;
 87	assert.notEqual(original[i], changed[i]); i++;
 88	if (!original[i - 1]) {
 89	    assert.equal((original[i] + 1) % 10, changed[i]); i++;
 90	    assert.equal((original[i] + 1) % 10, changed[i]); i++;
 91	    assert.equal((original[i] + 1) % 10, changed[i]); i++;
 92	}
 93	assert.notEqual(original[i], changed[i]); i++;
 94	assert.notEqual(original[i], changed[i]); i++;
 95	if (!original[i - 1])
 96	    assert.equal((original[i] + 1) % 9, changed[i]);
 97	i++;
 98
 99    });
100    
101});