Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / api / log_private / syslog_parser_unittest.cc
blobee5196b6a39630cb3d0f39527011f1f632c77128
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <string>
6 #include <vector>
8 #include "base/memory/linked_ptr.h"
9 #include "chrome/browser/extensions/api/log_private/filter_handler.h"
10 #include "chrome/browser/extensions/api/log_private/log_parser.h"
11 #include "chrome/browser/extensions/api/log_private/syslog_parser.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace extensions {
15 namespace {
17 const char kKernelLogEntry[] =
18 "2014-08-18T14:04:58.606132-07:00 kernel: [269374.012690] "
19 "cfg80211: World regulatory domain updated:";
21 const char kShillLogEntry[] =
22 "2014-08-15T11:20:24.575058-07:00 shill[1018]: "
23 "[INFO:service.cc(290)] Disconnecting from service 32: Unload";
25 const char kWpaSupplicantLogEntry[] =
26 "2014-08-15T12:36:06.137021-07:00 wpa_supplicant[818]: "
27 "nl80211: Received scan results (0 BSSes)";
29 } // namespace
31 class ExtensionSyslogParserTest : public testing::Test {
34 TEST_F(ExtensionSyslogParserTest, ParseLog) {
35 std::vector<linked_ptr<api::log_private::LogEntry> > output;
36 api::log_private::Filter filter;
37 FilterHandler filter_handler(filter);
38 SyslogParser p;
40 // Test kernel log
41 p.Parse(kKernelLogEntry, &output, &filter_handler);
42 ASSERT_EQ(1u, output.size());
43 EXPECT_EQ("unknown", output[0]->level);
44 EXPECT_EQ("kernel", output[0]->process);
45 EXPECT_EQ("unknown", output[0]->process_id);
46 EXPECT_EQ(kKernelLogEntry, output[0]->full_entry);
47 EXPECT_DOUBLE_EQ(1408395898606.132, output[0]->timestamp);
49 // Test shill log
50 p.Parse(kShillLogEntry, &output, &filter_handler);
51 ASSERT_EQ(2u, output.size());
52 EXPECT_EQ("info", output[1]->level);
53 EXPECT_EQ("shill", output[1]->process);
54 EXPECT_EQ("1018", output[1]->process_id);
55 EXPECT_EQ(kShillLogEntry, output[1]->full_entry);
56 EXPECT_DOUBLE_EQ(1408126824575.058, output[1]->timestamp);
58 // Test WpaSupplicant log
59 p.Parse(kWpaSupplicantLogEntry, &output, &filter_handler);
60 ASSERT_EQ(3u, output.size());
61 EXPECT_EQ("unknown", output[2]->level);
62 EXPECT_EQ("wpa_supplicant", output[2]->process);
63 EXPECT_EQ("818", output[2]->process_id);
64 EXPECT_EQ(kWpaSupplicantLogEntry, output[2]->full_entry);
65 EXPECT_DOUBLE_EQ(1408131366137.021, output[2]->timestamp);
68 } // namespace extensions