summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/installer_util_test_common.cc
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 18:21:00 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 18:21:00 +0000
commita7db59a612909895bc4cfefb38da59eb16afd630 (patch)
tree05e2e29fed798e7a8b83444af7d9817b168da063 /chrome/installer/util/installer_util_test_common.cc
parentcfc888a562b3b6d3e613f008d5997fe0345e7181 (diff)
downloadchromium_src-a7db59a612909895bc4cfefb38da59eb16afd630.zip
chromium_src-a7db59a612909895bc4cfefb38da59eb16afd630.tar.gz
chromium_src-a7db59a612909895bc4cfefb38da59eb16afd630.tar.bz2
Move CopyFileHierarchy to a common test namespace and also use it in MoveTreeWorkItemTest.MoveDirectoryDestExistsCheckForDuplicatesFull.
Unflakes that test. TBR=thakis@chromium.org (for chrome\chrome_installer.gypi). BUG=156374 TEST=installer_util_unittests.exe (ran all of them to make sure no other test was affected) Review URL: https://chromiumcodereview.appspot.com/11340049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165962 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/installer_util_test_common.cc')
-rw-r--r--chrome/installer/util/installer_util_test_common.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/chrome/installer/util/installer_util_test_common.cc b/chrome/installer/util/installer_util_test_common.cc
new file mode 100644
index 0000000..708d6c3
--- /dev/null
+++ b/chrome/installer/util/installer_util_test_common.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 2011 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 "chrome/installer/util/installer_util_test_common.h"
+
+#include <windows.h>
+#include <shellapi.h>
+
+#include "base/file_path.h"
+#include "base/string16.h"
+
+namespace installer {
+
+namespace test {
+
+bool CopyFileHierarchy(const FilePath& from, const FilePath& to) {
+ // In SHFILEOPSTRUCT below, |pFrom| and |pTo| have to be double-null
+ // terminated: http://msdn.microsoft.com/library/bb759795.aspx
+ string16 double_null_from(from.value());
+ double_null_from.push_back(L'\0');
+ string16 double_null_to(to.value());
+ double_null_to.push_back(L'\0');
+
+ SHFILEOPSTRUCT file_op = {};
+ file_op.wFunc = FO_COPY;
+ file_op.pFrom = double_null_from.c_str();
+ file_op.pTo = double_null_to.c_str();
+ file_op.fFlags = FOF_NO_UI;
+
+ return (SHFileOperation(&file_op) == 0 && !file_op.fAnyOperationsAborted);
+}
+
+} // namespace test
+
+} // namespace installer