apps:  Update regex for DisconnectReason log lines

Update regex for processing DisconnectReason property updates to
properly track log messages.

Sample line from log:
[2015-07-16T18:29:51.680057+00:00] [00:58:33.324] WiFi mlan0 supplicant
updated DisconnectReason to 7
[2015-07-16T18:30:02.459548+00:00] [00:58:44.103] WiFi mlan0 supplicant
updated DisconnectReason to -3 (was 7)

The log line will appear in the manager summary and will be highlighted
in the log text.

BUG=chromium:511479
TEST=checked manually and ran "grunt test" with the added test

Change-Id: I451aaa20082bd753663b60abecf65aa4c12a83c1
diff --git a/netlog_summary.js b/netlog_summary.js
index 4f8959f..ad8b37f 100644
--- a/netlog_summary.js
+++ b/netlog_summary.js
@@ -375,9 +375,9 @@
     }
   },
   'disconnect_reason': {
-    re: /\] (.*DisconnectReason (-?\d*)(?: was )?(-?\d*))/,
+    re: /\] (.*DisconnectReason to (-?\d*)( \(was (-?\d*)\))?)/,
     handler: function(processingState, result) {
-      // new reason code at result[2] old reason (if applicable) result[3]
+      // new reason code at result[2] old reason (if applicable) result[4]
       addNote(processingState.currentManager,
               processingState.time[0],
               result[1]);
diff --git a/test/spec/NetlogSummarySpec.js b/test/spec/NetlogSummarySpec.js
index 5d4a622..4d49470 100644
--- a/test/spec/NetlogSummarySpec.js
+++ b/test/spec/NetlogSummarySpec.js
@@ -100,4 +100,32 @@
     expect(logSummary.logStartTime).toEqual(Date.parse(time1));
     expect(logSummary.logEndTime).toEqual(Date.parse(time1));
   });
+
+  it('should properly handle DisconnectReason updates', function() {
+    var log = [
+        time1 + ' INFO shill[2590]: [INFO:wifi.cc(872)] WiFi mlan0 ' +
+            'supplicant updated DisconnectReason to -3',
+        time1 + ' INFO shill[2590]: [INFO:wifi.cc(872)] WiFi mlan0 ' +
+            'supplicant updated DisconnectReason to -3 (was 7)',
+        time1 + ' INFO shill[2590]: [INFO:wifi.cc(872)] WiFi mlan0 ' +
+            'supplicant updated DisconnectReason to 3 (was -7)',
+        time1 + ' INFO shill[2590]: [INFO:wifi.cc(872)] WiFi mlan0 ' +
+            'supplicant updated DisconnectReason to -3 (was -7)',
+        time1 + ' INFO shill[2590]: [INFO:wifi.cc(872)] WiFi mlan0 ' +
+            'supplicant updated DisconnectReason to 3'
+    ];
+    var match = log[0].match(netlogSummary.taggedLines['disconnect_reason'].re);
+    expect(match[2]).toEqual('-3');
+    match = log[1].match(netlogSummary.taggedLines['disconnect_reason'].re);
+    expect(match[2]).toEqual('-3');
+    expect(match[4]).toEqual('7');
+    match = log[2].match(netlogSummary.taggedLines['disconnect_reason'].re);
+    expect(match[2]).toEqual('3');
+    expect(match[4]).toEqual('-7');
+    match = log[3].match(netlogSummary.taggedLines['disconnect_reason'].re);
+    expect(match[2]).toEqual('-3');
+    expect(match[4]).toEqual('-7');
+    match = log[4].match(netlogSummary.taggedLines['disconnect_reason'].re);
+    expect(match[2]).toEqual('3');
+    });
 });