diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-24 01:21:11 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-24 01:21:11 +0000 |
commit | 4ae6aa038cd22a0d1a3b5e3cae28bcf91c6cc7ff (patch) | |
tree | 82d618525b5736fd6de362e13d84003d52bbcae1 /chrome_frame | |
parent | 86d9efe067316564973691781dbf750fd2570a27 (diff) | |
download | chromium_src-4ae6aa038cd22a0d1a3b5e3cae28bcf91c6cc7ff.zip chromium_src-4ae6aa038cd22a0d1a3b5e3cae28bcf91c6cc7ff.tar.gz chromium_src-4ae6aa038cd22a0d1a3b5e3cae28bcf91c6cc7ff.tar.bz2 |
More non-debug logging in Chrome Frame tests.
There are only good reasons to not use DLOG and DVLOG in test code.
Also, avoid a potential race by setting up ChromeFrameTestWithWebServer expectations before launching the browser.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9838058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 38 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_ui_test_utils.cc | 18 | ||||
-rw-r--r-- | chrome_frame/test/ie_event_sink.cc | 34 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.cc | 4 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.h | 4 | ||||
-rw-r--r-- | chrome_frame/test/simulate_input.cc | 5 | ||||
-rw-r--r-- | chrome_frame/test/test_server.cc | 6 | ||||
-rw-r--r-- | chrome_frame/test/test_with_web_server.cc | 16 | ||||
-rw-r--r-- | chrome_frame/test/win_event_receiver.cc | 4 |
9 files changed, 64 insertions, 65 deletions
diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 59b542a..77f02fb 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -70,8 +70,8 @@ BOOL CALLBACK CloseWindowsThreadCallback(HWND hwnd, LPARAM param) { } count++; } else { - DLOG(WARNING) << "Skipping disabled window: " - << base::StringPrintf(L"%08X", hwnd); + LOG(WARNING) << "Skipping disabled window: " + << base::StringPrintf(L"%08X", hwnd); } } return TRUE; // continue enumeration @@ -297,7 +297,7 @@ BOOL LowIntegrityToken::Impersonate() { BOOL ok = ::OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE, &process_token_handle); if (!ok) { - DLOG(ERROR) << "::OpenProcessToken failed: " << GetLastError(); + LOG(ERROR) << "::OpenProcessToken failed: " << GetLastError(); return ok; } @@ -308,7 +308,7 @@ BOOL LowIntegrityToken::Impersonate() { TOKEN_QUERY | TOKEN_IMPERSONATE | TOKEN_ADJUST_DEFAULT, NULL, SecurityImpersonation, TokenImpersonation, &impersonation_token_handle); if (!ok) { - DLOG(ERROR) << "::DuplicateTokenEx failed: " << GetLastError(); + LOG(ERROR) << "::DuplicateTokenEx failed: " << GetLastError(); return ok; } @@ -319,7 +319,7 @@ BOOL LowIntegrityToken::Impersonate() { TOKEN_MANDATORY_LABEL tml = {0}; ok = ::ConvertStringSidToSid(SDDL_ML_LOW, &integrity_sid); if (!ok) { - DLOG(ERROR) << "::ConvertStringSidToSid failed: " << GetLastError(); + LOG(ERROR) << "::ConvertStringSidToSid failed: " << GetLastError(); return ok; } @@ -329,7 +329,7 @@ BOOL LowIntegrityToken::Impersonate() { &tml, sizeof(tml) + ::GetLengthSid(integrity_sid)); ::LocalFree(integrity_sid); if (!ok) { - DLOG(ERROR) << "::SetTokenInformation failed: " << GetLastError(); + LOG(ERROR) << "::SetTokenInformation failed: " << GetLastError(); return ok; } @@ -338,7 +338,7 @@ BOOL LowIntegrityToken::Impersonate() { if (ok) { impersonated_ = true; } else { - DLOG(ERROR) << "::ImpersonateLoggedOnUser failed: " << GetLastError(); + LOG(ERROR) << "::ImpersonateLoggedOnUser failed: " << GetLastError(); } return ok; @@ -521,8 +521,8 @@ bool AddCFMetaTag(std::string* html_data) { head = html + strlen("<html>"); html_data->insert(head, "<head></head>"); } else { - DLOG(ERROR) << "Meta tag will not be injected " - << "because the html tag could not be found"; + LOG(ERROR) << "Meta tag will not be injected " + << "because the html tag could not be found"; } } if (head != std::string::npos) { @@ -535,7 +535,7 @@ bool AddCFMetaTag(std::string* html_data) { CloseIeAtEndOfScope::~CloseIeAtEndOfScope() { int closed = CloseAllIEWindows(); - DLOG_IF(ERROR, closed != 0) << "Closed " << closed << " windows forcefully"; + LOG_IF(ERROR, closed != 0) << "Closed " << closed << " windows forcefully"; } // Attempt to connect to a running crash_service instance. Success occurs if we @@ -590,8 +590,8 @@ bool DetectRunningCrashService(int timeout_ms) { base::ProcessHandle StartCrashService() { if (DetectRunningCrashService(kCrashServiceStartupTimeoutMs)) { - DVLOG(1) << "crash_service.exe is already running. We will use the " - "existing process and leave it running after tests complete."; + VLOG(1) << "crash_service.exe is already running. We will use the " + "existing process and leave it running after tests complete."; return NULL; } @@ -603,25 +603,25 @@ base::ProcessHandle StartCrashService() { base::ProcessHandle crash_service = NULL; - DVLOG(1) << "Starting crash_service.exe so you know if a test crashes!"; + VLOG(1) << "Starting crash_service.exe so you know if a test crashes!"; FilePath crash_service_path = exe_dir.AppendASCII("crash_service.exe"); if (!base::LaunchProcess(crash_service_path.value(), base::LaunchOptions(), &crash_service)) { - DLOG(ERROR) << "Couldn't start crash_service.exe"; + LOG(ERROR) << "Couldn't start crash_service.exe"; return NULL; } base::Time start = base::Time::Now(); if (DetectRunningCrashService(kCrashServiceStartupTimeoutMs)) { - DVLOG(1) << "crash_service.exe is ready for clients in " - << (base::Time::Now() - start).InMilliseconds() << " ms."; + VLOG(1) << "crash_service.exe is ready for clients in " + << (base::Time::Now() - start).InMilliseconds() << " ms."; return crash_service; } else { - DLOG(ERROR) << "crash_service.exe failed to accept client connections " - "within " << kCrashServiceStartupTimeoutMs << " ms. " - "Terminating it now."; + LOG(ERROR) << "crash_service.exe failed to accept client connections " + "within " << kCrashServiceStartupTimeoutMs << " ms. " + "Terminating it now."; // First check to see if it's even still running just to minimize the // likelihood of spurious error messages from KillProcess. diff --git a/chrome_frame/test/chrome_frame_ui_test_utils.cc b/chrome_frame/test/chrome_frame_ui_test_utils.cc index ffec433..0f557b3 100644 --- a/chrome_frame/test/chrome_frame_ui_test_utils.cc +++ b/chrome_frame/test/chrome_frame_ui_test_utils.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -186,15 +186,14 @@ bool AccObject::GetRoleText(std::wstring* role_text) { *role_text = role_text_array; return true; } else { - DLOG(ERROR) << "GetRoleText failed for role: " - << V_I4(&role_variant); + LOG(ERROR) << "GetRoleText failed for role: " << V_I4(&role_variant); } } else if (role_variant.type() == VT_BSTR) { *role_text = V_BSTR(&role_variant); return true; } else { - DLOG(ERROR) << "Role was unexpected variant type: " - << role_variant.type(); + LOG(ERROR) << "Role was unexpected variant type: " + << role_variant.type(); } } return false; @@ -242,8 +241,9 @@ bool AccObject::GetLocationInClient(gfx::Rect* client_location) { return false; POINT offset = {0, 0}; if (!::ScreenToClient(container_window, &offset)) { - DLOG(ERROR) << "Could not convert from screen to client coordinates for " - << "window containing accessibility object: " << GetDescription(); + LOG(ERROR) << "Could not convert from screen to client coordinates for " + "window containing accessibility object: " + << GetDescription(); return false; } location.Offset(offset.x, offset.y); @@ -525,8 +525,8 @@ AccObject* AccObject::CreateFromVariant(AccObject* object, bool AccObject::PostMouseClickAtCenter(int button_down, int button_up) { std::wstring class_name; if (!GetWindowClassName(&class_name)) { - DLOG(ERROR) << "Could not get class name of window for accessibility " - << "object: " << GetDescription(); + LOG(ERROR) << "Could not get class name of window for accessibility " + << "object: " << GetDescription(); return false; } gfx::Rect location; diff --git a/chrome_frame/test/ie_event_sink.cc b/chrome_frame/test/ie_event_sink.cc index bdff4d2..0e1f8d0 100644 --- a/chrome_frame/test/ie_event_sink.cc +++ b/chrome_frame/test/ie_event_sink.cc @@ -266,7 +266,7 @@ void IEEventSink::Uninitialize() { web_browser2_.Release(); if (!process.IsValid()) { - DLOG_IF(WARNING, !process.IsValid()) + LOG_IF(WARNING, !process.IsValid()) << base::StringPrintf("OpenProcess failed: %i", ::GetLastError()); return; } @@ -562,7 +562,7 @@ STDMETHODIMP_(void) IEEventSink::OnDownloadBegin() { STDMETHODIMP_(void) IEEventSink::OnNewWindow2(IDispatch** dispatch, VARIANT_BOOL* s) { - DVLOG(1) << __FUNCTION__; + VLOG(1) << __FUNCTION__; EXPECT_TRUE(dispatch); if (!dispatch) @@ -589,7 +589,7 @@ STDMETHODIMP_(void) IEEventSink::OnNewWindow2(IDispatch** dispatch, STDMETHODIMP_(void) IEEventSink::OnNavigateError(IDispatch* dispatch, VARIANT* url, VARIANT* frame_name, VARIANT* status_code, VARIANT* cancel) { - DVLOG(1) << __FUNCTION__; + VLOG(1) << __FUNCTION__; if (listener_) listener_->OnNavigateError(dispatch, url, frame_name, status_code, cancel); } @@ -598,8 +598,8 @@ STDMETHODIMP IEEventSink::OnBeforeNavigate2( IDispatch* dispatch, VARIANT* url, VARIANT* flags, VARIANT* target_frame_name, VARIANT* post_data, VARIANT* headers, VARIANT_BOOL* cancel) { - DVLOG(1) << __FUNCTION__ - << base::StringPrintf("%ls - 0x%08X", url->bstrVal, this); + VLOG(1) << __FUNCTION__ << " " + << base::StringPrintf("%ls - 0x%08X", url->bstrVal, this); // Reset any existing reference to chrome frame since this is a new // navigation. DisconnectFromChromeFrame(); @@ -611,7 +611,7 @@ STDMETHODIMP IEEventSink::OnBeforeNavigate2( STDMETHODIMP_(void) IEEventSink::OnNavigateComplete2( IDispatch* dispatch, VARIANT* url) { - DVLOG(1) << __FUNCTION__; + VLOG(1) << __FUNCTION__; ConnectToChromeFrame(); if (listener_) listener_->OnNavigateComplete2(dispatch, url); @@ -619,7 +619,7 @@ STDMETHODIMP_(void) IEEventSink::OnNavigateComplete2( STDMETHODIMP_(void) IEEventSink::OnDocumentComplete( IDispatch* dispatch, VARIANT* url) { - DVLOG(1) << __FUNCTION__; + VLOG(1) << __FUNCTION__; EXPECT_TRUE(url); if (!url) return; @@ -629,8 +629,8 @@ STDMETHODIMP_(void) IEEventSink::OnDocumentComplete( STDMETHODIMP_(void) IEEventSink::OnFileDownload( VARIANT_BOOL active_doc, VARIANT_BOOL* cancel) { - DVLOG(1) << __FUNCTION__ - << base::StringPrintf(" 0x%08X ad=%i", this, active_doc); + VLOG(1) << __FUNCTION__ << " " + << base::StringPrintf(" 0x%08X ad=%i", this, active_doc); if (listener_) { listener_->OnFileDownload(active_doc, cancel); } else { @@ -641,7 +641,7 @@ STDMETHODIMP_(void) IEEventSink::OnFileDownload( STDMETHODIMP_(void) IEEventSink::OnNewWindow3( IDispatch** dispatch, VARIANT_BOOL* cancel, DWORD flags, BSTR url_context, BSTR url) { - DVLOG(1) << __FUNCTION__; + VLOG(1) << __FUNCTION__; EXPECT_TRUE(dispatch); if (!dispatch) return; @@ -666,7 +666,7 @@ STDMETHODIMP_(void) IEEventSink::OnNewWindow3( } STDMETHODIMP_(void) IEEventSink::OnQuit() { - DVLOG(1) << __FUNCTION__; + VLOG(1) << __FUNCTION__; did_receive_on_quit_ = true; @@ -687,32 +687,32 @@ STDMETHODIMP IEEventSink::Invoke(DISPID dispid, REFIID riid, LCID lcid, } HRESULT IEEventSink::OnLoad(const VARIANT* param) { - DVLOG(1) << __FUNCTION__ << " " << param->bstrVal; + VLOG(1) << __FUNCTION__ << " " << param->bstrVal; base::win::ScopedVariant stack_object(*param); if (chrome_frame_) { if (listener_) listener_->OnLoad(param->bstrVal); } else { - DLOG(WARNING) << "Invalid chrome frame pointer"; + LOG(WARNING) << "Invalid chrome frame pointer"; } return S_OK; } HRESULT IEEventSink::OnLoadError(const VARIANT* param) { - DVLOG(1) << __FUNCTION__ << " " << param->bstrVal; + VLOG(1) << __FUNCTION__ << " " << param->bstrVal; if (chrome_frame_) { if (listener_) listener_->OnLoadError(param->bstrVal); } else { - DLOG(WARNING) << "Invalid chrome frame pointer"; + LOG(WARNING) << "Invalid chrome frame pointer"; } return S_OK; } HRESULT IEEventSink::OnMessage(const VARIANT* param) { - DVLOG(1) << __FUNCTION__ << " " << param; + VLOG(1) << __FUNCTION__ << " " << param; if (!chrome_frame_.get()) { - DLOG(WARNING) << "Invalid chrome frame pointer"; + LOG(WARNING) << "Invalid chrome frame pointer"; return S_OK; } diff --git a/chrome_frame/test/mock_ie_event_sink_test.cc b/chrome_frame/test/mock_ie_event_sink_test.cc index c31bb62..c858362 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.cc +++ b/chrome_frame/test/mock_ie_event_sink_test.cc @@ -32,7 +32,7 @@ void MockIEEventSink::OnDocumentComplete(IDispatch* dispatch, VARIANT* url) { renderer_window, OBJID_CLIENT, 0L); } else { - DVLOG(1) << "Browser does not have renderer window"; + VLOG(1) << "Browser does not have renderer window"; } OnLoad(IN_IE, V_BSTR(url)); } @@ -60,7 +60,7 @@ ExpectationSet MockIEEventSink::ExpectNavigationCardinality( // TODO(kkania): Consider avoiding this problem by creating a mock without // the OnFileDownload call or by removing the dependency of some tests on // InSequence. - DLOG_IF(WARNING, complete_cardinality.ConservativeUpperBound() > 1000) + LOG_IF(WARNING, complete_cardinality.ConservativeUpperBound() > 1000) << "Cardinality upper bound may be too great to be split up into single " "expect statements. If you do not require this navigation to be in " "sequence, do not call this method."; diff --git a/chrome_frame/test/mock_ie_event_sink_test.h b/chrome_frame/test/mock_ie_event_sink_test.h index 3b636c8..721a157 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.h +++ b/chrome_frame/test/mock_ie_event_sink_test.h @@ -45,7 +45,7 @@ class MockIEEventSink : public IEEventListener { ~MockIEEventSink() { Detach(); int reference_count = event_sink_->reference_count(); - DLOG_IF(ERROR, reference_count != 1) + LOG_IF(ERROR, reference_count != 1) << "Event sink is still referenced externally: ref count = " << reference_count; event_sink_->Release(); @@ -167,7 +167,7 @@ class MockPropertyNotifySinkListener : public PropertyNotifySinkListener { ~MockPropertyNotifySinkListener() { Detach(); sink_->set_listener(NULL); - DLOG_IF(ERROR, sink_->m_dwRef != 1) + LOG_IF(ERROR, sink_->m_dwRef != 1) << "Event sink is still referenced externally: ref count = " << sink_->m_dwRef; sink_->Release(); diff --git a/chrome_frame/test/simulate_input.cc b/chrome_frame/test/simulate_input.cc index 583bc56..2ee8cd7 100644 --- a/chrome_frame/test/simulate_input.cc +++ b/chrome_frame/test/simulate_input.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -101,7 +101,7 @@ bool EnsureProcessInForeground(base::ProcessId process_id) { PidAndWindow paw = { process_id }; EnumWindows(FindWindowInProcessCallback, reinterpret_cast<LPARAM>(&paw)); if (!IsWindow(paw.hwnd)) { - DLOG(ERROR) << "failed to find process window"; + LOG(ERROR) << "failed to find process window"; return false; } @@ -259,4 +259,3 @@ void SendStringA(const std::string& s) { } } // namespace simulate_input - diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc index 4b7b2a2..f7a3abd 100644 --- a/chrome_frame/test/test_server.cc +++ b/chrome_frame/test/test_server.cc @@ -323,8 +323,8 @@ void ConfigurableConnection::SendChunk() { int bytes_to_send = std::min(options_.chunk_size_, size - cur_pos_); socket_->Send(chunk_ptr, bytes_to_send); - DVLOG(1) << "Sent(" << cur_pos_ << "," << bytes_to_send << "): " - << base::StringPiece(chunk_ptr, bytes_to_send); + VLOG(1) << "Sent(" << cur_pos_ << "," << bytes_to_send << "): " + << base::StringPiece(chunk_ptr, bytes_to_send); cur_pos_ += bytes_to_send; if (cur_pos_ < size) { @@ -366,7 +366,7 @@ void ConfigurableConnection::SendWithOptions(const std::string& headers, if (options_.speed_ == SendOptions::IMMEDIATE_HEADERS_DELAYED_CONTENT) { socket_->Send(headers); socket_->Send(content_length_header, true); - DVLOG(1) << "Headers sent: " << headers << content_length_header; + VLOG(1) << "Headers sent: " << headers << content_length_header; data_.append(content); } diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc index 2021731..e01733e 100644 --- a/chrome_frame/test/test_with_web_server.cc +++ b/chrome_frame/test/test_with_web_server.cc @@ -179,10 +179,10 @@ void ChromeFrameTestWithWebServer::CloseBrowser() { if (wait == WAIT_OBJECT_0) { browser_handle_.Close(); } else { - DLOG(ERROR) << "WaitForSingleObject returned " << wait; + LOG(ERROR) << "WaitForSingleObject returned " << wait; } } else { - DLOG(ERROR) << "No attempts to close browser windows"; + LOG(ERROR) << "No attempts to close browser windows"; } if (browser_handle_.IsValid()) { @@ -214,9 +214,9 @@ const wchar_t kPostedResultSubstring[] = L"/writefile/"; void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( BrowserKind browser, const wchar_t* page, const char* result) { - ASSERT_TRUE(LaunchBrowser(browser, page)); server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), kPostedResultSubstring); + ASSERT_TRUE(LaunchBrowser(browser, page)); WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); ASSERT_EQ(result, server_mock_.posted_result()); } @@ -261,9 +261,9 @@ void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, EXPECT_TRUE(version_info); EXPECT_FALSE(version.empty()); - EXPECT_TRUE(LaunchBrowser(browser, page)); server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), kPostedResultSubstring); + EXPECT_TRUE(LaunchBrowser(browser, page)); WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result())); } @@ -350,8 +350,8 @@ void MockWebServer::SendResponseHelper( headers); } else { EXPECT_TRUE(net::GetMimeTypeFromFile(file_path, &content_type)); - DVLOG(1) << "Going to send file (" << WideToUTF8(file_path.value()) - << ") with content type (" << content_type << ")"; + VLOG(1) << "Going to send file (" << WideToUTF8(file_path.value()) + << ") with content type (" << content_type << ")"; headers = CreateHttpHeaders(invocation, add_no_cache_header, content_type); } @@ -366,8 +366,8 @@ void MockWebServer::SendResponseHelper( << "meta tag to HTML file."; } } else { - DVLOG(1) << "Going to send 404 for non-existent file (" - << WideToUTF8(file_path.value()) << ")"; + VLOG(1) << "Going to send 404 for non-existent file (" + << WideToUTF8(file_path.value()) << ")"; headers = "HTTP/1.1 404 Not Found"; body = ""; } diff --git a/chrome_frame/test/win_event_receiver.cc b/chrome_frame/test/win_event_receiver.cc index fbc21f2..7277b49 100644 --- a/chrome_frame/test/win_event_receiver.cc +++ b/chrome_frame/test/win_event_receiver.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -58,7 +58,7 @@ bool WinEventReceiver::InitializeHook(DWORD event_min, DWORD event_max) { hook_ = SetWinEventHook(event_min, event_max, NULL, reinterpret_cast<WINEVENTPROC>(hook_stub_->code()), 0, 0, WINEVENT_OUTOFCONTEXT); - DLOG_IF(ERROR, hook_ == NULL) << "Unable to SetWinEvent hook"; + LOG_IF(ERROR, hook_ == NULL) << "Unable to SetWinEvent hook"; return hook_ != NULL; } |