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

Unified Diff: chrome/installer/mac/app/testing/SystemInfo_test.mm

Issue 2137743002: Added test files for SystemInfo.m and OmahaXMLRequest.m. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Completed both test files Created 4 years, 5 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/installer/mac/app/testing/SystemInfo_test.mm
diff --git a/chrome/installer/mac/app/testing/SystemInfo_test.mm b/chrome/installer/mac/app/testing/SystemInfo_test.mm
new file mode 100644
index 0000000000000000000000000000000000000000..00c597f80ead208d35052ab92ed6eddbebefa5fc
--- /dev/null
+++ b/chrome/installer/mac/app/testing/SystemInfo_test.mm
@@ -0,0 +1,51 @@
+// Copyright 2016 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 "../SystemInfo.h"
Mark Mentovai 2016/07/15 21:56:09 #import
Anna Zeng 2016/07/22 16:58:02 Done.
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class SystemInfoTest : public ::testing::Test {};
Mark Mentovai 2016/07/15 21:56:09 Don’t need this at all. You haven’t used it, since
Anna Zeng 2016/07/22 16:58:02 Done.
+
+TEST(SystemInfoTest, getArchDoesNotReturnNil) {
+ EXPECT_NE([SystemInfo getArch], nil);
Mark Mentovai 2016/07/15 21:56:09 EXPECT_TRUE is fine.
Anna Zeng 2016/07/22 16:58:02 Done.
+}
+
+TEST(SystemInfoTest, getArchReturnsAString) {
+ EXPECT_TRUE([[SystemInfo getArch] isKindOfClass:[NSString class]]);
+}
+
+TEST(SystemInfoTest, getArchReturnsAtLeastThreeCharacters) {
+ EXPECT_GE((int)[[SystemInfo getArch] length], 3);
Mark Mentovai 2016/07/15 21:56:09 You’ve got three tests where I think that one will
Anna Zeng 2016/07/22 01:45:37 So... you mean that we want the code to work ONLY
Mark Mentovai 2016/07/22 13:55:49 Remember the macro that we stuck at the top of Sys
Anna Zeng 2016/07/22 16:58:02 Done.
+}
+
+TEST(SystemInfoTest, getOSVersionDoesNotReturnNil) {
+ EXPECT_NE([SystemInfo getOSVersion], nil);
+}
+
+TEST(SystemInfoTest, getOSVersionReturnsAString) {
+ EXPECT_TRUE([[SystemInfo getOSVersion] isKindOfClass:[NSString class]]);
+}
+
+TEST(SystemInfoTest, getOSVersionReturnsAtLeastThreeCharacters) {
+ EXPECT_GE((int)[[SystemInfo getOSVersion] length], 3);
+}
+
+TEST(SystemInfoTest, getOSVersionContainsPeriodDelimiters) {
+ EXPECT_NE([[SystemInfo getOSVersion] rangeOfString:@"."
+ options:NSCaseInsensitiveSearch]
+ .location,
+ (unsigned)NSNotFound);
+}
+
+TEST(SystemInfoTest, getOSVersionReturnsNumbers) {
Mark Mentovai 2016/07/15 21:56:09 Similar here. Let’s just make sure that the format
Anna Zeng 2016/07/22 16:58:02 Done.
+ NSArray* substrings =
+ [[SystemInfo getOSVersion] componentsSeparatedByString:@"."];
+ for (NSString* s in substrings) {
+ EXPECT_TRUE(([s intValue] != 0) || [s isEqualToString:@"0"]);
+ }
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698