| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/test/launcher/unit_test_launcher.h" | 7 #include "base/test/launcher/unit_test_launcher.h" |
| 8 #include "base/test/test_suite.h" | 8 #include "base/test/test_suite.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 #if defined(OS_MACOSX) | 11 #if defined(OS_MACOSX) |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/mac/bundle_locations.h" | 13 #include "base/mac/bundle_locations.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/test/mock_chrome_application_mac.h" | 15 #include "base/test/mock_chrome_application_mac.h" |
| 16 #include "ui/base/material_design/material_design_controller.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 class ShellDialogsTestSuite : public base::TestSuite { | 22 class ShellDialogsTestSuite : public base::TestSuite { |
| 22 public: | 23 public: |
| 23 ShellDialogsTestSuite(int argc, char** argv); | 24 ShellDialogsTestSuite(int argc, char** argv); |
| 24 | 25 |
| 25 protected: | 26 protected: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 42 | 43 |
| 43 // Set up framework bundle so that tests on Mac can access nib files. | 44 // Set up framework bundle so that tests on Mac can access nib files. |
| 44 base::FilePath path; | 45 base::FilePath path; |
| 45 PathService::Get(base::DIR_EXE, &path); | 46 PathService::Get(base::DIR_EXE, &path); |
| 46 // The three DirName() calls strip "Contents/MacOS/<binary>" from the path. | 47 // The three DirName() calls strip "Contents/MacOS/<binary>" from the path. |
| 47 path = path.DirName().DirName().DirName(); | 48 path = path.DirName().DirName().DirName(); |
| 48 path = path.Append(FILE_PATH_LITERAL("shell_dialogs_unittests.app")); | 49 path = path.Append(FILE_PATH_LITERAL("shell_dialogs_unittests.app")); |
| 49 base::mac::SetOverrideFrameworkBundlePath(path); | 50 base::mac::SetOverrideFrameworkBundlePath(path); |
| 50 | 51 |
| 51 // Setup resource bundle. | 52 // Setup resource bundle. |
| 53 ui::MaterialDesignController::Initialize(); |
| 52 ui::ResourceBundle::InitSharedInstanceWithLocale( | 54 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 53 "en-US", nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 55 "en-US", nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
| 54 #endif | 56 #endif |
| 55 } | 57 } |
| 56 | 58 |
| 57 void ShellDialogsTestSuite::Shutdown() { | 59 void ShellDialogsTestSuite::Shutdown() { |
| 58 #if defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
| 59 ui::ResourceBundle::CleanupSharedInstance(); | 61 ui::ResourceBundle::CleanupSharedInstance(); |
| 60 base::mac::SetOverrideFrameworkBundle(NULL); | 62 base::mac::SetOverrideFrameworkBundle(NULL); |
| 61 #endif | 63 #endif |
| 62 base::TestSuite::Shutdown(); | 64 base::TestSuite::Shutdown(); |
| 63 } | 65 } |
| 64 | 66 |
| 65 } // namespace | 67 } // namespace |
| 66 | 68 |
| 67 int main(int argc, char** argv) { | 69 int main(int argc, char** argv) { |
| 68 ShellDialogsTestSuite test_suite(argc, argv); | 70 ShellDialogsTestSuite test_suite(argc, argv); |
| 69 | 71 |
| 70 return base::LaunchUnitTests( | 72 return base::LaunchUnitTests( |
| 71 argc, argv, | 73 argc, argv, |
| 72 base::Bind(&ShellDialogsTestSuite::Run, base::Unretained(&test_suite))); | 74 base::Bind(&ShellDialogsTestSuite::Run, base::Unretained(&test_suite))); |
| 73 } | 75 } |
| OLD | NEW |