summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 09:47:03 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 09:47:03 +0000
commita711df1011fa2236f7c3e4749e6bae293ee36cd7 (patch)
tree79179b1c2d9145a670dc8b86ba62201c4e07c2ec
parentf1212bdd5b485d5ee20f9f1ed428f036fba54611 (diff)
downloadchromium_src-a711df1011fa2236f7c3e4749e6bae293ee36cd7.zip
chromium_src-a711df1011fa2236f7c3e4749e6bae293ee36cd7.tar.gz
chromium_src-a711df1011fa2236f7c3e4749e6bae293ee36cd7.tar.bz2
PrepopulateRespectBlank working, lets check the other test that was disabled
at the same time. I am removing traces from two tests since I think the problem with those tests have been fixed. By suppressing the crash server window on the try servers and ensuring Chrome is in the foreground it looks like the test now works. I went back in time through pages of try server logs and it seems to work. I am also enabling my other test that was disabled at the same time, since I think that test will probably work now. I moved the window caption check to that file, so we can see if we still have the same problem when it fails. BUG=62936, 62937 TEST=This CL is all about tests. Review URL: http://codereview.chromium.org/5769003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69112 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_focus_uitest.cc54
-rw-r--r--chrome/browser/ui/views/find_bar_host_interactive_uitest.cc96
2 files changed, 52 insertions, 98 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 7d81feb..836b335 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -8,6 +8,7 @@
#include "base/format_macros.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_window.h"
@@ -41,6 +42,11 @@
#include "chrome/browser/gtk/view_id_util.h"
#endif
+#if defined(OS_WIN)
+#include <windows.h>
+#include <Psapi.h>
+#endif
+
#if defined(OS_LINUX)
#define MAYBE_FocusTraversal FocusTraversal
#define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial
@@ -72,6 +78,49 @@ const char kStealFocusPage[] = "files/focus/page_steals_focus.html";
const char kTypicalPage[] = "files/focus/typical_page.html";
const char kTypicalPageName[] = "typical_page.html";
+// Test to make sure Chrome is in the foreground as we start testing. This is
+// required for tests that synthesize input to the Chrome window.
+bool ChromeInForeground() {
+#if defined(OS_WIN)
+ HWND window = ::GetForegroundWindow();
+ std::wstring caption;
+ std::wstring filename;
+ int len = ::GetWindowTextLength(window) + 1;
+ ::GetWindowText(window, WriteInto(&caption, len), len);
+ bool chrome_window_in_foreground =
+ EndsWith(caption, L" - Google Chrome", true) ||
+ EndsWith(caption, L" - Chromium", true);
+ if (!chrome_window_in_foreground) {
+ DWORD process_id;
+ int thread_id = ::GetWindowThreadProcessId(window, &process_id);
+
+ base::ProcessHandle process;
+ if (base::OpenProcessHandleWithAccess(process_id,
+ PROCESS_QUERY_LIMITED_INFORMATION,
+ &process)) {
+ len = MAX_PATH;
+ if (!GetProcessImageFileName(process, WriteInto(&filename, len), len)) {
+ int error = GetLastError();
+ filename = std::wstring(L"Unable to read filename for process id '" +
+ base::IntToString16(process_id) +
+ L"' (error ") +
+ base::IntToString16(error) + L")";
+ }
+ base::CloseProcessHandle(process);
+ }
+ }
+ EXPECT_TRUE(chrome_window_in_foreground)
+ << "Chrome must be in the foreground when running interactive tests\n"
+ << "Process in foreground: " << filename.c_str() << "\n"
+ << "Window: " << window << "\n"
+ << "Caption: " << caption.c_str();
+ return chrome_window_in_foreground;
+#else
+ // Windows only at the moment.
+ return true;
+#endif
+}
+
class BrowserFocusTest : public InProcessBrowserTest {
public:
BrowserFocusTest() {
@@ -652,8 +701,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) {
}
// Make sure Find box can request focus, even when it is already open.
-// Disabled, http://crbug.com/62936.
-IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FindFocusTest) {
+IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_TRUE(test_server()->Start());
@@ -661,6 +709,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FindFocusTest) {
GURL url = test_server()->GetURL(kTypicalPage);
ui_test_utils::NavigateToURL(browser(), url);
+ EXPECT_TRUE(ChromeInForeground());
+
#if defined(OS_MACOSX)
// Press Cmd+F, which will make the Find box open and request focus.
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
diff --git a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
index d4151c2..cb3d364 100644
--- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
@@ -4,7 +4,6 @@
#include "app/keyboard_codes.h"
#include "base/process_util.h"
-#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/tab_contents/tab_contents.h"
@@ -20,11 +19,6 @@
#include "views/focus/focus_manager.h"
#include "views/view.h"
-#if defined(OS_WIN)
-#include <windows.h>
-#include <Psapi.h>
-#endif
-
namespace {
// The delay waited after sending an OS simulated event.
@@ -45,55 +39,6 @@ class FindInPageTest : public InProcessBrowserTest {
}
};
-void Checkpoint(const char* message, const base::TimeTicks& start_time) {
- LOG(INFO) << message << " : "
- << (base::TimeTicks::Now() - start_time).InMilliseconds()
- << " ms" << std::flush;
-}
-
-// Test to make sure Chrome is in the foreground as we start testing. This is
-// required for tests that synthesize input to the Chrome window.
-bool ChromeInForeground() {
-#if defined(OS_WIN)
- HWND window = ::GetForegroundWindow();
- std::wstring caption;
- std::wstring filename;
- int len = ::GetWindowTextLength(window) + 1;
- ::GetWindowText(window, WriteInto(&caption, len), len);
- bool chrome_window_in_foreground =
- (caption == L"about:blank - Google Chrome") ||
- (caption == L"about:blank - Chromium");
- if (!chrome_window_in_foreground) {
- DWORD process_id;
- int thread_id = ::GetWindowThreadProcessId(window, &process_id);
-
- base::ProcessHandle process;
- if (base::OpenProcessHandleWithAccess(process_id,
- PROCESS_QUERY_LIMITED_INFORMATION,
- &process)) {
- len = MAX_PATH;
- if (!GetProcessImageFileName(process, WriteInto(&filename, len), len)) {
- int error = GetLastError();
- filename = std::wstring(L"Unable to read filename for process id '" +
- base::IntToString16(process_id) +
- L"' (error ") +
- base::IntToString16(error) + L")";
- }
- base::CloseProcessHandle(process);
- }
- }
- EXPECT_TRUE(chrome_window_in_foreground)
- << "Chrome must be in the foreground when running interactive tests\n"
- << "Process in foreground: " << filename.c_str() << "\n"
- << "Window: " << window << "\n"
- << "Caption: " << caption.c_str();
- return chrome_window_in_foreground;
-#else
- // Windows only at the moment.
- return true;
-#endif
-}
-
} // namespace
IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
@@ -176,74 +121,51 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
}
IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestoreOnTabSwitch) {
- base::TimeTicks start_time = base::TimeTicks::Now();
- Checkpoint("Starting test server", start_time);
-
ASSERT_TRUE(test_server()->Start());
// First we navigate to our test page (tab A).
GURL url = test_server()->GetURL(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
- Checkpoint("Calling Find", start_time);
-
browser()->Find();
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
- Checkpoint("GetFindBarTesting", start_time);
-
FindBarTesting* find_bar =
browser()->GetFindBarController()->find_bar()->GetFindBarTesting();
- Checkpoint("Search for 'a'", start_time);
-
// Search for 'a'.
ui_test_utils::FindInPage(browser()->GetSelectedTabContents(),
ASCIIToUTF16("a"), true, false, NULL);
EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText());
- Checkpoint("Open tab B", start_time);
-
// Open another tab (tab B).
browser()->AddSelectedTabWithURL(url, PageTransition::TYPED);
ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
- Checkpoint("Open find", start_time);
-
// Make sure Find box is open.
browser()->Find();
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
- Checkpoint("Search for 'b'", start_time);
-
// Search for 'b'.
ui_test_utils::FindInPage(browser()->GetSelectedTabContents(),
ASCIIToUTF16("b"), true, false, NULL);
EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText());
- Checkpoint("Focus location bar", start_time);
-
// Set focus away from the Find bar (to the Location bar).
browser()->FocusLocationBar();
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
- Checkpoint("Select tab A", start_time);
-
// Select tab A. Find bar should get focus.
browser()->SelectTabContentsAt(0, true);
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText());
- Checkpoint("Select tab B", start_time);
-
// Select tab B. Location bar should get focus.
browser()->SelectTabContentsAt(1, true);
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
-
- Checkpoint("Test done", start_time);
}
// This tests that whenever you clear values from the Find box and close it that
@@ -255,71 +177,53 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) {
return;
#endif
- base::TimeTicks start_time = base::TimeTicks::Now();
- Checkpoint("Starting test server", start_time);
-
ASSERT_TRUE(test_server()->Start());
// Make sure Chrome is in the foreground, otherwise sending input
// won't do anything and the test will hang.
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
- EXPECT_TRUE(ChromeInForeground());
// First we navigate to any page.
- Checkpoint("Navigating", start_time);
GURL url = test_server()->GetURL(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
// Show the Find bar.
- Checkpoint("Showing Find window", start_time);
browser()->GetFindBarController()->Show();
// Search for "a".
- Checkpoint("Search for 'a'", start_time);
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), app::VKEY_A, false, false, false, false));
// We should find "a" here.
- Checkpoint("GetFindBarText", start_time);
EXPECT_EQ(ASCIIToUTF16("a"), GetFindBarText());
// Delete "a".
- Checkpoint("Delete 'a'", start_time);
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), app::VKEY_BACK, false, false, false, false));
// Validate we have cleared the text.
- Checkpoint("Validate clear", start_time);
EXPECT_EQ(string16(), GetFindBarText());
// Close the Find box.
- Checkpoint("Close find", start_time);
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), app::VKEY_ESCAPE, false, false, false, false));
// Show the Find bar.
- Checkpoint("Showing Find window", start_time);
browser()->GetFindBarController()->Show();
// After the Find box has been reopened, it should not have been prepopulated
// with "a" again.
- Checkpoint("GetFindBarText", start_time);
EXPECT_EQ(string16(), GetFindBarText());
// Close the Find box.
- Checkpoint("Press Esc", start_time);
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), app::VKEY_ESCAPE, false, false, false, false));
// Press F3 to trigger FindNext.
- Checkpoint("Press F3", start_time);
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), app::VKEY_F3, false, false, false, false));
// After the Find box has been reopened, it should still have no prepopulate
// value.
- Checkpoint("GetFindBarText", start_time);
EXPECT_EQ(string16(), GetFindBarText());
-
- Checkpoint("Test completed", start_time);
}