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
3 // found in the LICENSE file.
7 #include "base/files/file_path.h"
8 #include "base/strings/string_util.h"
9 #include "ios/chrome/app/safe_mode_util.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h"
18 typedef PlatformTest SafeModeUtilTest
;
20 TEST_F(SafeModeUtilTest
, GetAllImages
) {
21 vector
<string
> images
= safe_mode_util::GetLoadedImages(nullptr);
22 // There should be loaded images.
23 EXPECT_GT(images
.size(), 0U);
25 // The libSystem dylib should always be present.
26 bool found_lib_system
= false;
27 string
lib_system_prefix("libSystem");
28 for (size_t i
= 0; i
< images
.size(); ++i
) {
29 string base_name
= base::FilePath(images
[i
]).BaseName().value();
30 if (base::StartsWith(base_name
, lib_system_prefix
,
31 base::CompareCase::SENSITIVE
)) {
32 found_lib_system
= true;
36 EXPECT_TRUE(found_lib_system
);
39 TEST_F(SafeModeUtilTest
, GetSomeImages
) {
40 vector
<string
> all_images
= safe_mode_util::GetLoadedImages(nullptr);
41 vector
<string
> usr_lib_images
= safe_mode_util::GetLoadedImages("/usr/lib/");
42 // There should be images under /usr/lib/, but not all of them are.
43 EXPECT_GT(usr_lib_images
.size(), 0U);
44 EXPECT_LT(usr_lib_images
.size(), all_images
.size());