blob: 4bbf78c729d86874016e238394b1b25df0c723fb [file] [log] [blame]
// Copyright 2016 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Jasmine test file for androidlog_summary.js.
*/
describe('AndroidlogSummary', function() {
var logSummary;
var basicLog;
var time1;
var time2;
var time3;
beforeEach(function() {
logSummary = new LogSummary();
time1 = '01-04 14:45:37.720';
time2 = '01-04 14:45:37.721';
time3 = '01-04 14:45:37.722';
basicLog = [
time1 + ' wpa_supplicant: Deauthentication frame IE(s)' +
' - hexdump(len=0): [NULL]',
time2 + ' wpa_supplicant: wlan0: CTRL-EVENT-DISCONNECTED' +
' bssid=24:de:c6:e0:89:51 reason=3 locally_generated=1',
time3 + ' WifiStateMachine: setDetailed state, old =OBTAINING_IPADDR' +
' and new state=DISCONNECTED hidden=false'
];
});
it('should properly match the Android log time format', function() {
var regexMatchTime = time1.match(logHelper.ANDROID_TIME_FORMAT)[0];
expect(regexMatchTime).toEqual(time1);
});
it('should detect wpa_supplicant disconnects and add to notes', function() {
androidlogSummary.processLogLines(basicLog, logSummary);
expect(logSummary.wifiStateMachines.length).toBe(1);
expect(logSummary.wifiStateMachines[0].notes.length).toBe(1);
});
it('should skip a log line without a valid timestamp', function() {
var log = [' wpa_supplicant: Deauthentication frame IE(s)' +
' - hexdump(len=0): [NULL]'];
androidlogSummary.processLogLines(log, logSummary);
expect(logSummary.wifiStateMachines.length).toBe(0);
expect(logSummary.logStartTime).toBe(-1);
});
});