From 58d58c7b9d95c57f6bd9266c15fe173bb3264cc8 Mon Sep 17 00:00:00 2001 From: "amit@chromium.org" Date: Fri, 5 Nov 2010 23:34:03 +0000 Subject: Some input tests no longer marked flaky For tests like CtrlW, CtrlN it's better to notice failures when they execute and not run them at all if the workstation is locked i.e. when they will certainly fail. Added a check to do exactly that :) BUG=none TESTS=CtrlR, CtrlW, CtrlN, CtrlF, AltD Review URL: http://codereview.chromium.org/4615001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65279 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome_frame/test/ui_test.cc | 35 ++++++++++++++++++++++++++++++----- chrome_frame/test_utils.cc | 18 ++++++++++++++++++ chrome_frame/test_utils.h | 2 ++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc index c308637..3d48f78 100644 --- a/chrome_frame/test/ui_test.cc +++ b/chrome_frame/test/ui_test.cc @@ -104,7 +104,12 @@ TEST_P(FullTabUITest, FLAKY_KeyboardBackForward) { } // Tests new window behavior with ctrl+N. -TEST_P(FullTabUITest, FLAKY_CtrlN) { +TEST_P(FullTabUITest, CtrlN) { + if (IsWorkstationLocked()) { + LOG(ERROR) << "This test cannot be run in a locked workstation."; + return; + } + bool is_cf = GetParam().invokes_cf(); if (!is_cf) { LOG(ERROR) << "Test not implemented for this configuration."; @@ -134,7 +139,12 @@ TEST_P(FullTabUITest, FLAKY_CtrlN) { } // Test that Ctrl+F opens the Find dialog. -TEST_P(FullTabUITest, FLAKY_CtrlF) { +TEST_P(FullTabUITest, CtrlF) { + if (IsWorkstationLocked()) { + LOG(ERROR) << "This test cannot be run in a locked workstation."; + return; + } + bool is_cf = GetParam().invokes_cf(); if (!is_cf) { LOG(ERROR) << "Test not implemented for this configuration."; @@ -163,7 +173,12 @@ TEST_P(FullTabUITest, FLAKY_CtrlF) { } // Test that ctrl+r does cause a refresh. -TEST_P(FullTabUITest, FLAKY_CtrlR) { +TEST_P(FullTabUITest, CtrlR) { + if (IsWorkstationLocked()) { + LOG(ERROR) << "This test cannot be run in a locked workstation."; + return; + } + InSequence expect_in_sequence_for_scope; EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), @@ -181,7 +196,12 @@ TEST_P(FullTabUITest, FLAKY_CtrlR) { } // Test window close with ctrl+w. -TEST_P(FullTabUITest, FLAKY_CtrlW) { +TEST_P(FullTabUITest, CtrlW) { + if (IsWorkstationLocked()) { + LOG(ERROR) << "This test cannot be run in a locked workstation."; + return; + } + EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(GetSimplePageUrl()))) .WillOnce(testing::DoAll( @@ -192,7 +212,12 @@ TEST_P(FullTabUITest, FLAKY_CtrlW) { } // Test address bar navigation with Alt+d and URL. -TEST_P(FullTabUITest, FLAKY_AltD) { +TEST_P(FullTabUITest, AltD) { + if (IsWorkstationLocked()) { + LOG(ERROR) << "This test cannot be run in a locked workstation."; + return; + } + EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(GetSimplePageUrl()))) .WillOnce(testing::DoAll( diff --git a/chrome_frame/test_utils.cc b/chrome_frame/test_utils.cc index a059b35..d146079 100644 --- a/chrome_frame/test_utils.cc +++ b/chrome_frame/test_utils.cc @@ -303,3 +303,21 @@ bool KillAllNamedProcessesWithArgument(const std::wstring& process_name, return result; } + +bool IsWorkstationLocked() { + bool is_locked = true; + HDESK input_desk = ::OpenInputDesktop(0, 0, GENERIC_READ); + if (input_desk) { + wchar_t name[256] = {0}; + DWORD needed = 0; + if (::GetUserObjectInformation(input_desk, + UOI_NAME, + name, + sizeof(name), + &needed)) { + is_locked = lstrcmpi(name, L"default") != 0; + } + ::CloseDesktop(input_desk); + } + return is_locked; +} diff --git a/chrome_frame/test_utils.h b/chrome_frame/test_utils.h index 70284fb..e0d5c27 100644 --- a/chrome_frame/test_utils.h +++ b/chrome_frame/test_utils.h @@ -90,5 +90,7 @@ class DispCallback bool KillAllNamedProcessesWithArgument(const std::wstring& process_name, const std::wstring& argument); +// If the workstation is locked and cannot receive user input. +bool IsWorkstationLocked(); #endif // CHROME_FRAME_TEST_UTILS_H_ -- cgit v1.1