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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system_logs/lsbrelease_log_source_unittest.cc
diff --git a/chrome/browser/chromeos/system_logs/lsbrelease_log_source_unittest.cc b/chrome/browser/chromeos/system_logs/lsbrelease_log_source_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fb160bb9f6cee4ff713c21ac58b5380def3a6c8a
--- /dev/null
+++ b/chrome/browser/chromeos/system_logs/lsbrelease_log_source_unittest.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/system_logs/lsbrelease_log_source.h"
+
+#include "base/basictypes.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+
+TEST(LSBReleaseLogSource, BasicFunctionality) {
+ std::string data("key=value\nkey2 = value2 ");
+ SystemLogsResponse response;
+ LsbReleaseLogSource::ParseLSBRelease(data, &response);
+ EXPECT_EQ(2U, response.size());
+ EXPECT_EQ("value", response["key"]);
+ EXPECT_TRUE(response.find("key2") != response.end());
satorux1 2012/08/15 22:01:09 remove this?
tudalex(Chromium) 2012/08/16 01:08:57 No. It checks if the spaces we're removed correctl
satorux1 2012/08/16 10:50:57 ah that makes sense.
+ EXPECT_EQ("value2", response["key2"]);
satorux1 2012/08/15 22:01:09 might want to add some comment: // Make sure extr
tudalex(Chromium) 2012/08/16 01:08:57 Done.
+}
+
+TEST(LSBReleaseLogSource, ValueMissing) {
+ std::string data("key=value\nkey2=\nkey3");
+ SystemLogsResponse response;
+ LsbReleaseLogSource::ParseLSBRelease(data, &response);
+ EXPECT_EQ(2U, response.size());
+ EXPECT_EQ("value", response["key"]);
+ EXPECT_EQ("<no value>", response["key2"]);
+ EXPECT_FALSE(response.find("key3") != response.end());
satorux1 2012/08/15 22:01:09 you can do: EXPECT_EQ(0U, response.count("key3"))
+}
+
+TEST(LSBReleaseLogSource, UTF8) {
satorux1 2012/08/15 22:01:09 BrokenUTF8
tudalex(Chromium) 2012/08/16 01:08:57 Done.
+ std::string data("key=value\nkey2=\nkey3=");
satorux1 2012/08/15 22:01:09 you could do "key=value\nkey2=\nkey3=\xFC" and rem
tudalex(Chromium) 2012/08/16 01:08:57 Done.
+ data.push_back(253);
+ data.append("ts\nkey4=value4");
+ SystemLogsResponse response;
+ LsbReleaseLogSource::ParseLSBRelease(data, &response);
+ EXPECT_EQ("<invalid characters in log entry>", response["key3"]);
+ EXPECT_EQ("value4", response["key4"]);
+}
+
+TEST(LSBReleasLogSource, NoKeyValuePair) {
satorux1 2012/08/15 22:01:09 you might also want to test with an empty string.
tudalex(Chromium) 2012/08/16 01:08:57 Done.
+ std::string data("random text without a meaning");
+ SystemLogsResponse response;
+ LsbReleaseLogSource::ParseLSBRelease(data, &response);
+ EXPECT_TRUE(response.empty());
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698