| 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 <objbase.h> | 5 #include <objbase.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/installer/util/master_preferences_constants.h" | 26 #include "chrome/installer/util/master_preferences_constants.h" |
| 27 #include "chrome/installer/util/product.h" | 27 #include "chrome/installer/util/product.h" |
| 28 #include "chrome/installer/util/shell_util.h" | 28 #include "chrome/installer/util/shell_util.h" |
| 29 #include "chrome/installer/util/util_constants.h" | 29 #include "chrome/installer/util/util_constants.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 class CreateVisualElementsManifestTest : public testing::Test { | 34 class CreateVisualElementsManifestTest : public testing::Test { |
| 35 protected: | 35 protected: |
| 36 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() override { |
| 37 // Create a temp directory for testing. | 37 // Create a temp directory for testing. |
| 38 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); | 38 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
| 39 | 39 |
| 40 version_ = Version("0.0.0.0"); | 40 version_ = Version("0.0.0.0"); |
| 41 | 41 |
| 42 version_dir_ = test_dir_.path().AppendASCII(version_.GetString()); | 42 version_dir_ = test_dir_.path().AppendASCII(version_.GetString()); |
| 43 ASSERT_TRUE(base::CreateDirectory(version_dir_)); | 43 ASSERT_TRUE(base::CreateDirectory(version_dir_)); |
| 44 | 44 |
| 45 manifest_path_ = | 45 manifest_path_ = |
| 46 test_dir_.path().Append(installer::kVisualElementsManifest); | 46 test_dir_.path().Append(installer::kVisualElementsManifest); |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void TearDown() OVERRIDE { | 49 virtual void TearDown() override { |
| 50 // Clean up test directory manually so we can fail if it leaks. | 50 // Clean up test directory manually so we can fail if it leaks. |
| 51 ASSERT_TRUE(test_dir_.Delete()); | 51 ASSERT_TRUE(test_dir_.Delete()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // The temporary directory used to contain the test operations. | 54 // The temporary directory used to contain the test operations. |
| 55 base::ScopedTempDir test_dir_; | 55 base::ScopedTempDir test_dir_; |
| 56 | 56 |
| 57 // A dummy version number used to create the version directory. | 57 // A dummy version number used to create the version directory. |
| 58 Version version_; | 58 Version version_; |
| 59 | 59 |
| 60 // The path to |test_dir_|\|version_|. | 60 // The path to |test_dir_|\|version_|. |
| 61 base::FilePath version_dir_; | 61 base::FilePath version_dir_; |
| 62 | 62 |
| 63 // The path to VisualElementsManifest.xml. | 63 // The path to VisualElementsManifest.xml. |
| 64 base::FilePath manifest_path_; | 64 base::FilePath manifest_path_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class InstallShortcutTest : public testing::Test { | 67 class InstallShortcutTest : public testing::Test { |
| 68 protected: | 68 protected: |
| 69 virtual void SetUp() OVERRIDE { | 69 virtual void SetUp() override { |
| 70 EXPECT_EQ(S_OK, CoInitialize(NULL)); | 70 EXPECT_EQ(S_OK, CoInitialize(NULL)); |
| 71 | 71 |
| 72 dist_ = BrowserDistribution::GetDistribution(); | 72 dist_ = BrowserDistribution::GetDistribution(); |
| 73 ASSERT_TRUE(dist_ != NULL); | 73 ASSERT_TRUE(dist_ != NULL); |
| 74 product_.reset(new installer::Product(dist_)); | 74 product_.reset(new installer::Product(dist_)); |
| 75 | 75 |
| 76 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 76 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 77 chrome_exe_ = temp_dir_.path().Append(installer::kChromeExe); | 77 chrome_exe_ = temp_dir_.path().Append(installer::kChromeExe); |
| 78 EXPECT_EQ(0, base::WriteFile(chrome_exe_, "", 0)); | 78 EXPECT_EQ(0, base::WriteFile(chrome_exe_, "", 0)); |
| 79 | 79 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 fake_common_desktop_.path().Append(shortcut_name); | 132 fake_common_desktop_.path().Append(shortcut_name); |
| 133 system_start_menu_shortcut_ = | 133 system_start_menu_shortcut_ = |
| 134 fake_common_start_menu_.path().Append( | 134 fake_common_start_menu_.path().Append( |
| 135 dist_->GetStartMenuShortcutSubfolder( | 135 dist_->GetStartMenuShortcutSubfolder( |
| 136 BrowserDistribution::SUBFOLDER_CHROME)) | 136 BrowserDistribution::SUBFOLDER_CHROME)) |
| 137 .Append(shortcut_name); | 137 .Append(shortcut_name); |
| 138 user_alternate_desktop_shortcut_ = | 138 user_alternate_desktop_shortcut_ = |
| 139 fake_user_desktop_.path().Append(alternate_shortcut_name); | 139 fake_user_desktop_.path().Append(alternate_shortcut_name); |
| 140 } | 140 } |
| 141 | 141 |
| 142 virtual void TearDown() OVERRIDE { | 142 virtual void TearDown() override { |
| 143 // Try to unpin potentially pinned shortcuts (although pinning isn't tested, | 143 // Try to unpin potentially pinned shortcuts (although pinning isn't tested, |
| 144 // the call itself might still have pinned the Start Menu shortcuts). | 144 // the call itself might still have pinned the Start Menu shortcuts). |
| 145 base::win::TaskbarUnpinShortcutLink( | 145 base::win::TaskbarUnpinShortcutLink( |
| 146 user_start_menu_shortcut_.value().c_str()); | 146 user_start_menu_shortcut_.value().c_str()); |
| 147 base::win::TaskbarUnpinShortcutLink( | 147 base::win::TaskbarUnpinShortcutLink( |
| 148 system_start_menu_shortcut_.value().c_str()); | 148 system_start_menu_shortcut_.value().c_str()); |
| 149 CoUninitialize(); | 149 CoUninitialize(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 installer::MasterPreferences* GetFakeMasterPrefs( | 152 installer::MasterPreferences* GetFakeMasterPrefs( |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 installer::EscapeXmlAttributeValueInSingleQuotes(&val); | 422 installer::EscapeXmlAttributeValueInSingleQuotes(&val); |
| 423 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); | 423 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { | 426 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { |
| 427 base::string16 val(L"Google Chrome"); | 427 base::string16 val(L"Google Chrome"); |
| 428 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; | 428 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; |
| 429 installer::EscapeXmlAttributeValueInSingleQuotes(&val); | 429 installer::EscapeXmlAttributeValueInSingleQuotes(&val); |
| 430 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); | 430 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); |
| 431 } | 431 } |
| OLD | NEW |