| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/installer/util/product.h" | 5 #include "chrome/installer/util/product.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/test_reg_util_win.h" | 14 #include "base/test/test_reg_util_win.h" |
| 15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/installer/util/browser_distribution.h" |
| 16 #include "chrome/installer/util/google_update_constants.h" | 17 #include "chrome/installer/util/google_update_constants.h" |
| 17 #include "chrome/installer/util/installation_state.h" | 18 #include "chrome/installer/util/installation_state.h" |
| 18 #include "chrome/installer/util/master_preferences.h" | 19 #include "chrome/installer/util/master_preferences.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 using base::win::RegKey; | 22 using base::win::RegKey; |
| 22 using installer::Product; | 23 using installer::Product; |
| 23 using installer::MasterPreferences; | 24 using installer::MasterPreferences; |
| 24 using registry_util::RegistryOverrideManager; | 25 using registry_util::RegistryOverrideManager; |
| 25 | 26 |
| 26 TEST(ProductTest, ProductInstallBasic) { | 27 TEST(ProductTest, ProductInstallBasic) { |
| 27 // TODO(tommi): We should mock this and use our mocked distribution. | 28 // TODO(tommi): We should mock this and use our mocked distribution. |
| 28 const bool multi_install = false; | 29 const bool multi_install = false; |
| 29 const bool system_level = true; | 30 const bool system_level = true; |
| 30 base::CommandLine cmd_line = base::CommandLine::FromString( | 31 base::CommandLine cmd_line = base::CommandLine::FromString( |
| 31 std::wstring(L"setup.exe") + | 32 std::wstring(L"setup.exe") + |
| 32 (multi_install ? L" --multi-install --chrome" : L"") + | 33 (multi_install ? L" --multi-install --chrome" : L"") + |
| 33 (system_level ? L" --system-level" : L"")); | 34 (system_level ? L" --system-level" : L"")); |
| 34 installer::MasterPreferences prefs(cmd_line); | 35 installer::MasterPreferences prefs(cmd_line); |
| 35 installer::InstallationState machine_state; | 36 installer::InstallationState machine_state; |
| 36 machine_state.Initialize(); | 37 machine_state.Initialize(); |
| 37 | 38 |
| 38 std::unique_ptr<Product> product = base::MakeUnique<Product>( | 39 std::unique_ptr<Product> product = |
| 39 BrowserDistribution::GetSpecificDistribution( | 40 base::MakeUnique<Product>(BrowserDistribution::GetDistribution()); |
| 40 BrowserDistribution::CHROME_BROWSER)); | |
| 41 product->InitializeFromPreferences(prefs); | 41 product->InitializeFromPreferences(prefs); |
| 42 BrowserDistribution* distribution = product->distribution(); | 42 BrowserDistribution* distribution = product->distribution(); |
| 43 EXPECT_EQ(BrowserDistribution::CHROME_BROWSER, distribution->GetType()); | |
| 44 | 43 |
| 45 base::FilePath user_data_dir; | 44 base::FilePath user_data_dir; |
| 46 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 45 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
| 47 EXPECT_FALSE(user_data_dir.empty()); | 46 EXPECT_FALSE(user_data_dir.empty()); |
| 48 | 47 |
| 49 base::FilePath program_files; | 48 base::FilePath program_files; |
| 50 ASSERT_TRUE(PathService::Get(base::DIR_PROGRAM_FILES, &program_files)); | 49 ASSERT_TRUE(PathService::Get(base::DIR_PROGRAM_FILES, &program_files)); |
| 51 // The User Data path should never be under program files, even though | 50 // The User Data path should never be under program files, even though |
| 52 // system_level is true. | 51 // system_level is true. |
| 53 EXPECT_EQ(std::wstring::npos, | 52 EXPECT_EQ(std::wstring::npos, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (chrome_state) | 96 if (chrome_state) |
| 98 EXPECT_TRUE(chrome_state->is_msi()); | 97 EXPECT_TRUE(chrome_state->is_msi()); |
| 99 } | 98 } |
| 100 } | 99 } |
| 101 | 100 |
| 102 TEST(ProductTest, LaunchChrome) { | 101 TEST(ProductTest, LaunchChrome) { |
| 103 // TODO(tommi): Test Product::LaunchChrome and | 102 // TODO(tommi): Test Product::LaunchChrome and |
| 104 // Product::LaunchChromeAndWait. | 103 // Product::LaunchChromeAndWait. |
| 105 NOTIMPLEMENTED(); | 104 NOTIMPLEMENTED(); |
| 106 } | 105 } |
| OLD | NEW |