| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 using content::OpenURLParams; | 90 using content::OpenURLParams; |
| 91 using content::RenderViewHost; | 91 using content::RenderViewHost; |
| 92 using content::RenderWidgetHost; | 92 using content::RenderWidgetHost; |
| 93 using content::Referrer; | 93 using content::Referrer; |
| 94 using content::WebContents; | 94 using content::WebContents; |
| 95 | 95 |
| 96 namespace ui_test_utils { | 96 namespace ui_test_utils { |
| 97 | 97 |
| 98 namespace { | 98 namespace { |
| 99 | 99 |
| 100 #if defined(OS_WIN) |
| 100 const char kSnapshotBaseName[] = "ChromiumSnapshot"; | 101 const char kSnapshotBaseName[] = "ChromiumSnapshot"; |
| 101 const char kSnapshotExtension[] = ".png"; | 102 const char kSnapshotExtension[] = ".png"; |
| 102 | 103 |
| 103 base::FilePath GetSnapshotFileName(const base::FilePath& snapshot_directory) { | 104 base::FilePath GetSnapshotFileName(const base::FilePath& snapshot_directory) { |
| 104 base::Time::Exploded the_time; | 105 base::Time::Exploded the_time; |
| 105 | 106 |
| 106 base::Time::Now().LocalExplode(&the_time); | 107 base::Time::Now().LocalExplode(&the_time); |
| 107 std::string filename(base::StringPrintf("%s%04d%02d%02d%02d%02d%02d%s", | 108 std::string filename(base::StringPrintf("%s%04d%02d%02d%02d%02d%02d%s", |
| 108 kSnapshotBaseName, the_time.year, the_time.month, the_time.day_of_month, | 109 kSnapshotBaseName, the_time.year, the_time.month, the_time.day_of_month, |
| 109 the_time.hour, the_time.minute, the_time.second, kSnapshotExtension)); | 110 the_time.hour, the_time.minute, the_time.second, kSnapshotExtension)); |
| 110 | 111 |
| 111 base::FilePath snapshot_file = snapshot_directory.AppendASCII(filename); | 112 base::FilePath snapshot_file = snapshot_directory.AppendASCII(filename); |
| 112 if (base::PathExists(snapshot_file)) { | 113 if (base::PathExists(snapshot_file)) { |
| 113 int index = 0; | 114 int index = 0; |
| 114 std::string suffix; | 115 std::string suffix; |
| 115 base::FilePath trial_file; | 116 base::FilePath trial_file; |
| 116 do { | 117 do { |
| 117 suffix = base::StringPrintf(" (%d)", ++index); | 118 suffix = base::StringPrintf(" (%d)", ++index); |
| 118 trial_file = snapshot_file.InsertBeforeExtensionASCII(suffix); | 119 trial_file = snapshot_file.InsertBeforeExtensionASCII(suffix); |
| 119 } while (base::PathExists(trial_file)); | 120 } while (base::PathExists(trial_file)); |
| 120 snapshot_file = trial_file; | 121 snapshot_file = trial_file; |
| 121 } | 122 } |
| 122 return snapshot_file; | 123 return snapshot_file; |
| 123 } | 124 } |
| 125 #endif // defined(OS_WIN) |
| 124 | 126 |
| 125 Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) { | 127 Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) { |
| 126 Browser* new_browser = GetBrowserNotInSet(excluded_browsers); | 128 Browser* new_browser = GetBrowserNotInSet(excluded_browsers); |
| 127 if (new_browser == NULL) { | 129 if (new_browser == NULL) { |
| 128 BrowserAddedObserver observer; | 130 BrowserAddedObserver observer; |
| 129 new_browser = observer.WaitForSingleNewBrowser(); | 131 new_browser = observer.WaitForSingleNewBrowser(); |
| 130 // The new browser should never be in |excluded_browsers|. | 132 // The new browser should never be in |excluded_browsers|. |
| 131 DCHECK(!ContainsKey(excluded_browsers, new_browser)); | 133 DCHECK(!ContainsKey(excluded_browsers, new_browser)); |
| 132 } | 134 } |
| 133 return new_browser; | 135 return new_browser; |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 void HistoryEnumerator::HistoryQueryComplete( | 531 void HistoryEnumerator::HistoryQueryComplete( |
| 530 const base::Closure& quit_task, | 532 const base::Closure& quit_task, |
| 531 HistoryService::Handle request_handle, | 533 HistoryService::Handle request_handle, |
| 532 history::QueryResults* results) { | 534 history::QueryResults* results) { |
| 533 for (size_t i = 0; i < results->size(); ++i) | 535 for (size_t i = 0; i < results->size(); ++i) |
| 534 urls_.push_back((*results)[i].url()); | 536 urls_.push_back((*results)[i].url()); |
| 535 quit_task.Run(); | 537 quit_task.Run(); |
| 536 } | 538 } |
| 537 | 539 |
| 538 } // namespace ui_test_utils | 540 } // namespace ui_test_utils |
| OLD | NEW |