OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "ios/chrome/app/safe_mode_util.h" | 9 #include "ios/chrome/app/safe_mode_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
12 | 12 |
13 using std::string; | 13 using std::string; |
14 using std::vector; | 14 using std::vector; |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 typedef PlatformTest SafeModeUtilTest; | 18 typedef PlatformTest SafeModeUtilTest; |
19 | 19 |
20 TEST_F(SafeModeUtilTest, GetAllImages) { | 20 TEST_F(SafeModeUtilTest, GetAllImages) { |
21 vector<string> images = safe_mode_util::GetLoadedImages(nullptr); | 21 vector<string> images = safe_mode_util::GetLoadedImages(nullptr); |
22 // There should be loaded images. | 22 // There should be loaded images. |
23 EXPECT_GT(images.size(), 0U); | 23 EXPECT_GT(images.size(), 0U); |
24 | 24 |
25 // The libSystem dylib should always be present. | 25 // The libSystem dylib should always be present. |
26 bool found_lib_system = false; | 26 bool found_lib_system = false; |
27 string lib_system_prefix("libSystem"); | 27 string lib_system_prefix("libSystem"); |
28 for (size_t i = 0; i < images.size(); ++i) { | 28 for (size_t i = 0; i < images.size(); ++i) { |
29 string base_name = base::FilePath(images[i]).BaseName().value(); | 29 string base_name = base::FilePath(images[i]).BaseName().value(); |
30 if (base::StartsWithASCII(base_name, lib_system_prefix, true)) { | 30 if (base::StartsWith(base_name, lib_system_prefix, |
| 31 base::CompareCase::SENSITIVE)) { |
31 found_lib_system = true; | 32 found_lib_system = true; |
32 break; | 33 break; |
33 } | 34 } |
34 } | 35 } |
35 EXPECT_TRUE(found_lib_system); | 36 EXPECT_TRUE(found_lib_system); |
36 } | 37 } |
37 | 38 |
38 TEST_F(SafeModeUtilTest, GetSomeImages) { | 39 TEST_F(SafeModeUtilTest, GetSomeImages) { |
39 vector<string> all_images = safe_mode_util::GetLoadedImages(nullptr); | 40 vector<string> all_images = safe_mode_util::GetLoadedImages(nullptr); |
40 vector<string> usr_lib_images = safe_mode_util::GetLoadedImages("/usr/lib/"); | 41 vector<string> usr_lib_images = safe_mode_util::GetLoadedImages("/usr/lib/"); |
41 // There should be images under /usr/lib/, but not all of them are. | 42 // There should be images under /usr/lib/, but not all of them are. |
42 EXPECT_GT(usr_lib_images.size(), 0U); | 43 EXPECT_GT(usr_lib_images.size(), 0U); |
43 EXPECT_LT(usr_lib_images.size(), all_images.size()); | 44 EXPECT_LT(usr_lib_images.size(), all_images.size()); |
44 } | 45 } |
45 | 46 |
46 } // namespace | 47 } // namespace |
OLD | NEW |