Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / ios / chrome / app / safe_mode_util_unittest.cc
blob3164d59fc7e13ebb4b5589efbc20fac831b2ce37
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.
5 #include <string.h>
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"
13 using std::string;
14 using std::vector;
16 namespace {
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 (StartsWithASCII(base_name, lib_system_prefix, true)) {
31 found_lib_system = true;
32 break;
35 EXPECT_TRUE(found_lib_system);
38 TEST_F(SafeModeUtilTest, GetSomeImages) {
39 vector<string> all_images = safe_mode_util::GetLoadedImages(nullptr);
40 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 EXPECT_GT(usr_lib_images.size(), 0U);
43 EXPECT_LT(usr_lib_images.size(), all_images.size());
46 } // namespace