From a7db59a612909895bc4cfefb38da59eb16afd630 Mon Sep 17 00:00:00 2001 From: "gab@chromium.org" Date: Mon, 5 Nov 2012 18:21:00 +0000 Subject: 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 --- .../installer/util/installer_util_test_common.cc | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 chrome/installer/util/installer_util_test_common.cc (limited to 'chrome/installer/util/installer_util_test_common.cc') 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 +#include + +#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 -- cgit v1.1