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

Unified Diff: base/sys_info_unittest.cc

Issue 2860663005: Implement SysInfo::HardwareModelName() on iOS. (Closed)
Patch Set: Use hw.machine and expand unit test to check format. Created 3 years, 7 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
« no previous file with comments | « base/sys_info_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_unittest.cc
diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc
index 94b5a8497167483ad74d3c841364c91be817c248..e9c2fd62d7e66cc8e40a008d88276aeb5020463a 100644
--- a/base/sys_info_unittest.cc
+++ b/base/sys_info_unittest.cc
@@ -7,6 +7,8 @@
#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/process/process_metrics.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
#include "base/sys_info.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -95,10 +97,17 @@ TEST_F(SysInfoTest, Uptime) {
EXPECT_GT(up_time_2.InMicroseconds(), up_time_1.InMicroseconds());
}
-#if defined(OS_MACOSX) && !defined(OS_IOS)
-TEST_F(SysInfoTest, HardwareModelName) {
+#if defined(OS_MACOSX)
+TEST_F(SysInfoTest, HardwareModelNameFormatMacAndiOS) {
std::string hardware_model = SysInfo::HardwareModelName();
- EXPECT_FALSE(hardware_model.empty());
+ ASSERT_FALSE(hardware_model.empty());
+ // Check that the model is of the expected format "Foo,Bar" where "Bar" is
+ // a number.
+ std::vector<StringPiece> pieces =
+ SplitStringPiece(hardware_model, ",", KEEP_WHITESPACE, SPLIT_WANT_ALL);
+ EXPECT_EQ(2u, pieces.size());
pkl (ping after 24h if needed) 2017/05/04 21:03:51 ASSERT_EQ? Otherwise pieces[1] may crash if pieces
Alexei Svitkine (slow) 2017/05/04 21:06:01 Right! Done.
+ int value;
+ EXPECT_TRUE(StringToInt(pieces[1], &value));
}
#endif
« no previous file with comments | « base/sys_info_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698