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

Unified Diff: chrome/test/base/interactive_test_utils_win.cc

Issue 11414223: Move the test functions that deal with focus to interactive_ui_tets_utils.h and into the interactiv… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/test/base/interactive_test_utils_win.cc
===================================================================
--- chrome/test/base/interactive_test_utils_win.cc (revision 170118)
+++ chrome/test/base/interactive_test_utils_win.cc (working copy)
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/test/base/ui_test_utils.h"
+#include "chrome/test/base/interactive_test_utils.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -17,41 +17,12 @@
#if defined(USE_AURA)
#include "chrome/browser/ui/host_desktop.h"
-#include "chrome/browser/ui/views/test/ui_test_utils_aura.h"
+#include "chrome/test/base/interactive_test_utils_aura.h"
#include "ui/aura/root_window.h"
#endif
namespace ui_test_utils {
-namespace {
-
-const char kSnapshotBaseName[] = "ChromiumSnapshot";
-const char kSnapshotExtension[] = ".png";
-
-FilePath GetSnapshotFileName(const FilePath& snapshot_directory) {
- base::Time::Exploded the_time;
-
- base::Time::Now().LocalExplode(&the_time);
- std::string filename(StringPrintf("%s%04d%02d%02d%02d%02d%02d%s",
- kSnapshotBaseName, the_time.year, the_time.month, the_time.day_of_month,
- the_time.hour, the_time.minute, the_time.second, kSnapshotExtension));
-
- FilePath snapshot_file = snapshot_directory.AppendASCII(filename);
- if (file_util::PathExists(snapshot_file)) {
- int index = 0;
- std::string suffix;
- FilePath trial_file;
- do {
- suffix = StringPrintf(" (%d)", ++index);
- trial_file = snapshot_file.InsertBeforeExtensionASCII(suffix);
- } while (file_util::PathExists(trial_file));
- snapshot_file = trial_file;
- }
- return snapshot_file;
-}
-
-} // namespace
-
void HideNativeWindow(gfx::NativeWindow window) {
#if defined(USE_AURA)
if (chrome::GetHostDesktopTypeForNativeWindow(window) ==
@@ -90,40 +61,4 @@
return GetForegroundWindow() == hwnd;
}
-bool SaveScreenSnapshotToDirectory(const FilePath& directory,
- FilePath* screenshot_path) {
- bool succeeded = false;
- FilePath out_path(GetSnapshotFileName(directory));
-
- MONITORINFO monitor_info = {};
- monitor_info.cbSize = sizeof(monitor_info);
- HMONITOR main_monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
- if (GetMonitorInfo(main_monitor, &monitor_info)) {
- RECT& rect = monitor_info.rcMonitor;
-
- std::vector<unsigned char> png_data;
- gfx::Rect bounds(
- gfx::Size(rect.right - rect.left, rect.bottom - rect.top));
- if (chrome::internal::GrabWindowSnapshot(NULL, &png_data, bounds) &&
- png_data.size() <= INT_MAX) {
- int bytes = static_cast<int>(png_data.size());
- int written = file_util::WriteFile(
- out_path, reinterpret_cast<char*>(&png_data[0]), bytes);
- succeeded = (written == bytes);
- }
- }
-
- if (succeeded && screenshot_path != NULL)
- *screenshot_path = out_path;
-
- return succeeded;
-}
-
-bool SaveScreenSnapshotToDesktop(FilePath* screenshot_path) {
- FilePath desktop;
-
- return PathService::Get(base::DIR_USER_DESKTOP, &desktop) &&
- SaveScreenSnapshotToDirectory(desktop, screenshot_path);
-}
-
} // namespace ui_test_utils

Powered by Google App Engine
This is Rietveld 408576698