Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10410)

Unified Diff: chrome/installer/setup/install_unittest.cc

Issue 10160011: Create VisualElementsManifest.xml from template -- install VisualElements in the version directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: single \n at EOF Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/setup/install_worker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/install_unittest.cc
diff --git a/chrome/installer/setup/install_unittest.cc b/chrome/installer/setup/install_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8d4606f8c32d9015fa745e3adf3b24b7464e8bcc
--- /dev/null
+++ b/chrome/installer/setup/install_unittest.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "base/file_util.h"
+#include "base/platform_file.h"
+#include "base/scoped_temp_dir.h"
+#include "base/string16.h"
+#include "base/utf_string_conversions.h"
+#include "base/version.h"
+#include "chrome/installer/setup/install.h"
+#include "chrome/installer/setup/setup_constants.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class CreateVisualElementsManifestTest : public testing::Test {
+ protected:
+ virtual void SetUp() OVERRIDE {
+ // Create a temp directory for testing.
+ ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
+
+ version_ = Version("0.0.0.0");
+
+ version_dir_ = test_dir_.path().AppendASCII(version_.GetString());
+ ASSERT_TRUE(file_util::CreateDirectory(version_dir_));
+
+ manifest_path_ =
+ test_dir_.path().Append(installer::kVisualElementsManifest);
+ }
+
+ virtual void TearDown() OVERRIDE {
+ // Clean up test directory manually so we can fail if it leaks.
+ ASSERT_TRUE(test_dir_.Delete());
+ }
+
+ // The temporary directory used to contain the test operations.
+ ScopedTempDir test_dir_;
+
+ // A dummy version number used to create the version directory.
+ Version version_;
+
+ // The path to |test_dir_|\|version_|.
+ FilePath version_dir_;
+
+ // The path to VisualElementsManifest.xml.
+ FilePath manifest_path_;
+};
+
+} // namespace
+
+// Test that VisualElementsManifest.xml is not created when VisualElements are
+// not present.
+TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) {
+ ASSERT_TRUE(
+ installer::CreateVisualElementsManifest(test_dir_.path(), version_));
+ ASSERT_FALSE(file_util::PathExists(manifest_path_));
+}
+
+// Test that VisualElementsManifest.xml is created with the correct content when
+// VisualElements are present.
+TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestCreated) {
+ ASSERT_TRUE(file_util::CreateDirectory(
+ version_dir_.Append(installer::kVisualElements)));
+ ASSERT_TRUE(
+ installer::CreateVisualElementsManifest(test_dir_.path(), version_));
+ ASSERT_TRUE(file_util::PathExists(manifest_path_));
+
+ std::string read_manifest;
+ ASSERT_TRUE(file_util::ReadFileToString(manifest_path_, &read_manifest));
+
+ static const char kExpectedManifest[] =
+ "<Application>\r\n"
+ " <VisualElements\r\n"
+ " DisplayName='Google Chrome'\r\n"
+ " Logo='0.0.0.0\\VisualElements\\Logo.png'\r\n"
+ " SmallLogo='0.0.0.0\\VisualElements\\SmallLogo.png'\r\n"
+ " ForegroundText='light'\r\n"
+ " BackgroundColor='white'>\r\n"
+ " <DefaultTile ShowName='allLogos'/>\r\n"
+ " <SplashScreen Image='0.0.0.0\\VisualElements\\splash-620x300.png'/>"
+ "\r\n"
+ " </VisualElements>\r\n"
+ "</Application>";
+
+ ASSERT_STREQ(kExpectedManifest, read_manifest.c_str());
+}
+
+TEST(EscapeXmlAttributeValueTest, EscapeCrazyValue) {
+ string16 val(L"This has 'crazy' \"chars\" && < and > signs.");
+ static const wchar_t kExpectedEscapedVal[] =
+ L"This has &apos;crazy&apos; \"chars\" &amp;&amp; &lt; and > signs.";
+ installer::EscapeXmlAttributeValueInSingleQuotes(&val);
+ ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
+}
+
+TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) {
+ string16 val(L"Google Chrome");
+ static const wchar_t kExpectedEscapedVal[] = L"Google Chrome";
+ installer::EscapeXmlAttributeValueInSingleQuotes(&val);
+ ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
+}
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/setup/install_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698