Index: chrome/installer/setup/install_unittest.cc |
diff --git a/chrome/installer/setup/install_unittest.cc b/chrome/installer/setup/install_unittest.cc |
index c9667854595f15629d8ff2b8c2516981fb70a3d2..3a194ea55673a3c159b5a96d514cf1ed2c030f47 100644 |
--- a/chrome/installer/setup/install_unittest.cc |
+++ b/chrome/installer/setup/install_unittest.cc |
@@ -9,18 +9,22 @@ |
#include <memory> |
#include <string> |
+#include <tuple> |
#include "base/base_paths.h" |
#include "base/files/file_path.h" |
#include "base/files/file_util.h" |
#include "base/files/scoped_temp_dir.h" |
#include "base/macros.h" |
+#include "base/memory/ptr_util.h" |
#include "base/strings/string16.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/test/scoped_path_override.h" |
#include "base/test/test_shortcut_win.h" |
#include "base/version.h" |
#include "base/win/shortcut.h" |
+#include "chrome/install_static/install_details.h" |
+#include "chrome/install_static/install_modes.h" |
#include "chrome/installer/setup/install_worker.h" |
#include "chrome/installer/setup/setup_constants.h" |
#include "chrome/installer/util/browser_distribution.h" |
@@ -35,9 +39,21 @@ |
namespace { |
-class CreateVisualElementsManifestTest : public testing::Test { |
+class CreateVisualElementsManifestTest |
+ : public ::testing::TestWithParam< |
+ std::tuple<install_static::InstallConstantIndex, const char*>> { |
protected: |
void SetUp() override { |
+ install_static::InstallConstantIndex mode_index; |
+ |
+ std::tie(mode_index, expected_manifest_) = GetParam(); |
+ |
+ // Set up an InstallDetails for the mode under test. |
+ std::unique_ptr<install_static::PrimaryInstallDetails> details = |
+ base::MakeUnique<install_static::PrimaryInstallDetails>(); |
+ details->set_mode(&install_static::kInstallModes[mode_index]); |
+ install_static::InstallDetails::SetForProcess(std::move(details)); |
+ |
// Create a temp directory for testing. |
ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
@@ -53,8 +69,14 @@ class CreateVisualElementsManifestTest : public testing::Test { |
void TearDown() override { |
// Clean up test directory manually so we can fail if it leaks. |
ASSERT_TRUE(test_dir_.Delete()); |
+ |
+ // Clear/free the test InstallDetails. |
+ install_static::InstallDetails::SetForProcess(nullptr); |
} |
+ // The expected contents of the manifest. |
+ const char* expected_manifest_ = nullptr; |
+ |
// The temporary directory used to contain the test operations. |
base::ScopedTempDir test_dir_; |
@@ -68,6 +90,47 @@ class CreateVisualElementsManifestTest : public testing::Test { |
base::FilePath manifest_path_; |
}; |
+constexpr char kExpectedPrimaryManifest[] = |
+ "<Application xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\r\n" |
+ " <VisualElements\r\n" |
+ " ShowNameOnSquare150x150Logo='on'\r\n" |
+ " Square150x150Logo='0.0.0.0\\VisualElements\\Logo.png'\r\n" |
+ " Square70x70Logo='0.0.0.0\\VisualElements\\SmallLogo.png'\r\n" |
+ " Square44x44Logo='0.0.0.0\\VisualElements\\SmallLogo.png'\r\n" |
+ " ForegroundText='light'\r\n" |
+ " BackgroundColor='#212121'/>\r\n" |
+ "</Application>\r\n"; |
+ |
+#if defined(GOOGLE_CHROME_BUILD) |
+constexpr char kExpectedCanaryManifest[] = |
+ "<Application xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\r\n" |
+ " <VisualElements\r\n" |
+ " ShowNameOnSquare150x150Logo='on'\r\n" |
+ " Square150x150Logo='0.0.0.0\\VisualElements\\LogoCanary.png'\r\n" |
+ " Square70x70Logo='0.0.0.0\\VisualElements\\SmallLogoCanary.png'\r\n" |
+ " Square44x44Logo='0.0.0.0\\VisualElements\\SmallLogoCanary.png'\r\n" |
+ " ForegroundText='light'\r\n" |
+ " BackgroundColor='#212121'/>\r\n" |
+ "</Application>\r\n"; |
+ |
+INSTANTIATE_TEST_CASE_P( |
+ GoogleChrome, |
+ CreateVisualElementsManifestTest, |
+ testing::Combine(testing::Values(install_static::STABLE_INDEX), |
+ testing::Values(kExpectedPrimaryManifest))); |
+INSTANTIATE_TEST_CASE_P( |
+ CanaryChrome, |
+ CreateVisualElementsManifestTest, |
+ testing::Combine(testing::Values(install_static::CANARY_INDEX), |
+ testing::Values(kExpectedCanaryManifest))); |
+#else |
+INSTANTIATE_TEST_CASE_P( |
+ Chromium, |
+ CreateVisualElementsManifestTest, |
+ testing::Combine(testing::Values(install_static::CHROMIUM_INDEX), |
+ testing::Values(kExpectedPrimaryManifest))); |
+#endif |
+ |
class InstallShortcutTest : public testing::Test { |
protected: |
void SetUp() override { |
@@ -202,7 +265,7 @@ class InstallShortcutTest : public testing::Test { |
// Test that VisualElementsManifest.xml is not created when VisualElements are |
// not present. |
-TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { |
+TEST_P(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { |
ASSERT_TRUE( |
installer::CreateVisualElementsManifest(test_dir_.GetPath(), version_)); |
ASSERT_FALSE(base::PathExists(manifest_path_)); |
@@ -210,7 +273,7 @@ TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { |
// Test that VisualElementsManifest.xml is created with the correct content when |
// VisualElements are present. |
-TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestCreated) { |
+TEST_P(CreateVisualElementsManifestTest, VisualElementsManifestCreated) { |
ASSERT_TRUE(base::CreateDirectory( |
version_dir_.Append(installer::kVisualElements))); |
ASSERT_TRUE( |
@@ -220,18 +283,7 @@ TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestCreated) { |
std::string read_manifest; |
ASSERT_TRUE(base::ReadFileToString(manifest_path_, &read_manifest)); |
- static const char kExpectedManifest[] = |
- "<Application xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\r\n" |
- " <VisualElements\r\n" |
- " ShowNameOnSquare150x150Logo='on'\r\n" |
- " Square150x150Logo='0.0.0.0\\VisualElements\\Logo.png'\r\n" |
- " Square70x70Logo='0.0.0.0\\VisualElements\\SmallLogo.png'\r\n" |
- " Square44x44Logo='0.0.0.0\\VisualElements\\SmallLogo.png'\r\n" |
- " ForegroundText='light'\r\n" |
- " BackgroundColor='#212121'/>\r\n" |
- "</Application>\r\n"; |
- |
- ASSERT_STREQ(kExpectedManifest, read_manifest.c_str()); |
+ ASSERT_STREQ(expected_manifest_, read_manifest.c_str()); |
} |
TEST_F(InstallShortcutTest, CreateAllShortcuts) { |