Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: chrome/browser/chromeos/system_logs/lsbrelease_log_source_unittest.cc

Issue 10827130: Refactoring the SysInfoProvider. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "chrome/browser/chromeos/system_logs/lsbrelease_log_source.h"
6
7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace chromeos {
11
12 TEST(LSBReleaseLogSource, BasicFunctionality) {
13 std::string data("key=value\nkey2 = value2 ");
14 SystemLogsResponse response;
15 LsbReleaseLogSource::ParseLSBRelease(data, &response);
16 EXPECT_EQ(2U, response.size());
17 EXPECT_EQ("value", response["key"]);
18
19 // Make sure extra white space is removed correctly. First from the key and
20 // then from the value.
21 EXPECT_EQ(1U, response.count("key2"));
22 EXPECT_EQ("value2", response["key2"]);
23 }
24
25 TEST(LSBReleaseLogSource, ValueMissing) {
26 std::string data("key=value\nkey2=\nkey3");
27 SystemLogsResponse response;
28 LsbReleaseLogSource::ParseLSBRelease(data, &response);
29 EXPECT_EQ(2U, response.size());
30 EXPECT_EQ("value", response["key"]);
31 EXPECT_EQ("<no value>", response["key2"]);
32 EXPECT_EQ(0U, response.count("key3"));
33 }
34
35 TEST(LSBReleaseLogSource, BrokenUTF8) {
36 std::string data("key=value\nkey2=\nkey3=\xFCts\nkey4=value4");
satorux1 2012/08/16 10:50:57 Please also test the broken UTF8 in a key.
tudalex(Chromium) 2012/08/16 22:33:03 Done.
37 SystemLogsResponse response;
38 LsbReleaseLogSource::ParseLSBRelease(data, &response);
39 EXPECT_EQ("<invalid characters in log entry>", response["key3"]);
40 EXPECT_EQ("value4", response["key4"]);
41 }
42
43 TEST(LSBReleasLogSource, NoKeyValuePair) {
44 SystemLogsResponse response;
45
46 std::string contents1("random text without a meaning");
47 LsbReleaseLogSource::ParseLSBRelease(contents1, &response);
48 EXPECT_TRUE(response.empty());
49
50 response.clear();
51 std::string contents2("");
satorux1 2012/08/16 10:50:57 Rather than doing this in the same test, it's clea
tudalex(Chromium) 2012/08/16 22:33:03 Done.
52 LsbReleaseLogSource::ParseLSBRelease(contents1, &response);
53 EXPECT_TRUE(response.empty());
54 }
55
56 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698