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

Unified Diff: chrome/installer/util/installer_util_test_common.cc

Issue 11340049: Move CopyFileHierarchy to a common test namespace and also use it in MoveTreeWorkItemTest.MoveDirec… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: and with the new files... Created 8 years, 2 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
Index: 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 0000000000000000000000000000000000000000..19e71b0a1b402b3dae04dee028394615382a1643
--- /dev/null
+++ b/chrome/installer/util/installer_util_test_common.cc
@@ -0,0 +1,35 @@
+// 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 <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

Powered by Google App Engine
This is Rietveld 408576698