diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 19:09:58 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 19:09:58 +0000 |
commit | 87930be9c2f649026664778f132b2a003984d489 (patch) | |
tree | a6556807d37941ac2bf8451087cf1f83717f6b8b | |
parent | 967c43ce2e52c96fb6f3a5c878d2973c7bcf2fc1 (diff) | |
download | chromium_src-87930be9c2f649026664778f132b2a003984d489.zip chromium_src-87930be9c2f649026664778f132b2a003984d489.tar.gz chromium_src-87930be9c2f649026664778f132b2a003984d489.tar.bz2 |
gtest / gmock shouldn't be in the shipping product
Remove dependencies from automation on testing libraries that pull in gtest / gmock directly or indirectly. Do this by pulling ASSERTs out of chrome code and putting them into test code instead. Also delete some unused code.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8584013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111187 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/chrome.gyp | 2 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 14 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 5 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.cc | 8 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.h | 7 | ||||
-rw-r--r-- | chrome/test/automation/dom_automation_browsertest.cc | 91 | ||||
-rw-r--r-- | chrome/test/automation/dom_element_proxy.cc | 43 | ||||
-rw-r--r-- | chrome/test/automation/dom_element_proxy.h | 22 | ||||
-rw-r--r-- | chrome/test/automation/extension_proxy.cc | 27 | ||||
-rw-r--r-- | chrome/test/automation/extension_proxy.h | 15 | ||||
-rw-r--r-- | chrome/test/automation/extension_proxy_uitest.cc | 63 | ||||
-rw-r--r-- | chrome/test/perf/startup_test.cc | 7 |
12 files changed, 134 insertions, 170 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index cecefaf..dfadbd0 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1237,9 +1237,7 @@ 'type': 'static_library', 'dependencies': [ 'chrome_resources.gyp:theme_resources', - '../base/base.gyp:test_support_base', '../skia/skia.gyp:skia', - '../testing/gtest.gyp:gtest', ], 'include_dirs': [ '..', diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 9788c29..27de278 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -4,8 +4,6 @@ #include "chrome/test/automation/automation_proxy.h" -#include <gtest/gtest.h> - #include <sstream> #include "base/basictypes.h" @@ -251,15 +249,9 @@ scoped_refptr<ExtensionProxy> AutomationProxy::InstallExtension( return ProxyObjectFromHandle<ExtensionProxy>(handle); } -void AutomationProxy::EnsureExtensionTestResult() { - bool result; - std::string message; - if (!Send(new AutomationMsg_WaitForExtensionTestResult(&result, - &message))) { - FAIL() << "Could not send WaitForExtensionTestResult message"; - return; - } - ASSERT_TRUE(result) << "Extension test message: " << message; +bool AutomationProxy::GetExtensionTestResult( + bool* result, std::string* message) { + return Send(new AutomationMsg_WaitForExtensionTestResult(result, message)); } bool AutomationProxy::GetBrowserWindowCount(int* num_windows) { diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 834023e..db3366c 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -203,8 +203,9 @@ class AutomationProxy : public IPC::Channel::Listener, scoped_refptr<ExtensionProxy> InstallExtension(const FilePath& extension_path, bool with_ui); - // Asserts that the next extension test result is true. - void EnsureExtensionTestResult(); + // Gets the next extension test result in |result|. Returns false if there + // was a problem sending the result querying RPC. + bool GetExtensionTestResult(bool* result, std::string* message); // Resets to the default theme. Returns true on success. bool ResetToDefaultTheme(); diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index b00c945..cc525ef 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -8,7 +8,6 @@ #include "base/json/json_reader.h" #include "base/logging.h" -#include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "base/time.h" #include "chrome/common/automation_constants.h" @@ -579,7 +578,8 @@ bool BrowserProxy::SendJSONRequest(const std::string& request, return result; } -bool BrowserProxy::GetInitialLoadTimes(float* min_start_time, +bool BrowserProxy::GetInitialLoadTimes(int timeout_ms, + float* min_start_time, float* max_stop_time, std::vector<float>* stop_times) { std::string json_response; @@ -587,9 +587,7 @@ bool BrowserProxy::GetInitialLoadTimes(float* min_start_time, *max_stop_time = 0; *min_start_time = -1; - if (!SendJSONRequest(kJSONCommand, - TestTimeouts::action_max_timeout_ms(), - &json_response)) { + if (!SendJSONRequest(kJSONCommand, timeout_ms, &json_response)) { // Older browser versions do not support GetInitialLoadTimes. // Fail gracefully and do not record them in this case. return false; diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h index d62c0fa..958f4ec 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -232,8 +232,11 @@ class BrowserProxy : public AutomationResourceProxy { // the time when loading stopped into |max_stop_time| (should be similar to // the delay that WaitForInitialLoads waits for), and a list of all // finished timestamps into |stop_times|. Returns true on success. - bool GetInitialLoadTimes(float* min_start_time, float* max_stop_time, - std::vector<float>* stop_times); + bool GetInitialLoadTimes( + int timeout_ms, + float* min_start_time, + float* max_stop_time, + std::vector<float>* stop_times); protected: diff --git a/chrome/test/automation/dom_automation_browsertest.cc b/chrome/test/automation/dom_automation_browsertest.cc index e8c623b..ba267d4 100644 --- a/chrome/test/automation/dom_automation_browsertest.cc +++ b/chrome/test/automation/dom_automation_browsertest.cc @@ -13,6 +13,43 @@ namespace { +// Asserts that |expected_text| matches all the text in this element. This +// includes the value of textfields and inputs. +void EnsureTextMatches( + DOMElementProxyRef proxy, const std::string& expected_text) { + std::string text; + ASSERT_TRUE(proxy->GetText(&text)); + ASSERT_EQ(expected_text, text); +} + +// Asserts that |expected_html| matches the element's inner html. +void EnsureInnerHTMLMatches( + DOMElementProxyRef proxy, const std::string& expected_html) { + std::string html; + ASSERT_TRUE(proxy->GetInnerHTML(&html)); + ASSERT_EQ(expected_html, html); +} + +// Asserts that |expected_name| matches the element's name. +void EnsureNameMatches( + DOMElementProxyRef proxy, const std::string& expected_name) { + std::string name; + ASSERT_TRUE(proxy->GetName(&name)); + ASSERT_EQ(expected_name, name); +} + +// Asserts that |expected_value| eventually matches the element's value for +// |attribute|. This function will block until the timeout is exceeded, in +// which case it will fail, or until the two values match. +void EnsureAttributeEventuallyMatches( + DOMElementProxyRef proxy, + const std::string& attribute, + const std::string& new_value) { + ASSERT_TRUE(proxy->is_valid()); + if (!proxy->DoesAttributeEventuallyMatch(attribute, new_value)) + FAIL() << "Executing or parsing JavaScript failed"; +} + // Tests the DOMAutomation framework for manipulating DOMElements within // browser tests. class DOMAutomationTest : public InProcessBrowserTest { @@ -46,15 +83,15 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, MAYBE_FindByXPath) { // Find first element. DOMElementProxyRef first_div = main_doc->FindElement(By::XPath("//div")); ASSERT_TRUE(first_div); - ASSERT_NO_FATAL_FAILURE(first_div->EnsureNameMatches("0")); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(first_div, "0")); // Find many elements. std::vector<DOMElementProxyRef> elements; ASSERT_TRUE(main_doc->FindElements(By::XPath("//div"), &elements)); ASSERT_EQ(2u, elements.size()); for (size_t i = 0; i < elements.size(); i++) { - ASSERT_NO_FATAL_FAILURE(elements[i]->EnsureNameMatches( - base::UintToString(i))); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches( + elements[i], base::UintToString(i))); } // Find 0 elements. @@ -77,7 +114,7 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, MAYBE_FindByXPath) { while (node) { nested_count++; span_name.append("span"); - ASSERT_NO_FATAL_FAILURE(node->EnsureNameMatches(span_name)); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(node, span_name)); node = node->FindElement(By::XPath("./span")); } ASSERT_EQ(3, nested_count); @@ -93,15 +130,15 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, FindBySelectors) { DOMElementProxyRef first_myclass = main_doc->FindElement(By::Selectors(".myclass")); ASSERT_TRUE(first_myclass); - ASSERT_NO_FATAL_FAILURE(first_myclass->EnsureNameMatches("0")); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(first_myclass, "0")); // Find many elements. std::vector<DOMElementProxyRef> elements; ASSERT_TRUE(main_doc->FindElements(By::Selectors(".myclass"), &elements)); ASSERT_EQ(2u, elements.size()); for (size_t i = 0; i < elements.size(); i++) { - ASSERT_NO_FATAL_FAILURE(elements[i]->EnsureNameMatches( - base::UintToString(i))); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches( + elements[i], base::UintToString(i))); } // Find 0 elements. @@ -121,7 +158,7 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, FindBySelectors) { while (node) { nested_count++; span_name.append("span"); - ASSERT_NO_FATAL_FAILURE(node->EnsureNameMatches(span_name)); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(node, span_name)); node = node->FindElement(By::Selectors("span")); } ASSERT_EQ(3, nested_count); @@ -142,15 +179,15 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, MAYBE_FindByText) { // Find first element. DOMElementProxyRef first_text = main_doc->FindElement(By::Text("div_text")); ASSERT_TRUE(first_text); - ASSERT_NO_FATAL_FAILURE(first_text->EnsureNameMatches("0")); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(first_text, "0")); // Find many elements. std::vector<DOMElementProxyRef> elements; ASSERT_TRUE(main_doc->FindElements(By::Text("div_text"), &elements)); ASSERT_EQ(2u, elements.size()); for (size_t i = 0; i < elements.size(); i++) { - ASSERT_NO_FATAL_FAILURE(elements[i]->EnsureNameMatches( - base::UintToString(i))); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches( + elements[i], base::UintToString(i))); } // Find 0 elements. @@ -166,7 +203,7 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, MAYBE_FindByText) { while (node) { nested_count++; span_name.append("span"); - ASSERT_NO_FATAL_FAILURE(node->EnsureNameMatches(span_name)); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(node, span_name)); node = node->FindElement(By::Text("span_text")); } ASSERT_EQ(3, nested_count); @@ -174,7 +211,7 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, MAYBE_FindByText) { // Find only visible text. DOMElementProxyRef shown_td = main_doc->FindElement(By::Text("table_text")); ASSERT_TRUE(shown_td); - ASSERT_NO_FATAL_FAILURE(shown_td->EnsureNameMatches("shown")); + ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(shown_td, "shown")); // Find text in inputs. ASSERT_TRUE(main_doc->FindElement(By::Text("textarea_text"))); @@ -189,7 +226,7 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, WaitFor1VisibleElement) { DOMElementProxyRef div = main_doc->WaitFor1VisibleElement(By::Selectors("div")); ASSERT_TRUE(div.get()); - ASSERT_NO_FATAL_FAILURE(div->EnsureInnerHTMLMatches("div_inner")); + ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(div, "div_inner")); } IN_PROC_BROWSER_TEST_F(DOMAutomationTest, WaitForElementsToDisappear) { @@ -210,8 +247,8 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, EnsureAttributeEventuallyMatches) { DOMElementProxyRef anchor = main_doc->FindElement(By::Selectors("a")); ASSERT_TRUE(anchor.get()); - ASSERT_NO_FATAL_FAILURE(anchor->EnsureAttributeEventuallyMatches( - "href", "http://www.google.com")); + ASSERT_NO_FATAL_FAILURE(EnsureAttributeEventuallyMatches( + anchor, "href", "http://www.google.com")); } IN_PROC_BROWSER_TEST_F(DOMAutomationTest, Frames) { @@ -231,10 +268,10 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, Frames) { DOMElementProxyRef frame_div = frame1->FindElement(By::XPath("/html/body/div")); ASSERT_TRUE(frame_div); - ASSERT_NO_FATAL_FAILURE(frame_div->EnsureInnerHTMLMatches("frame 1")); + ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(frame_div, "frame 1")); frame_div = frame2->FindElement(By::XPath("/html/body/div")); ASSERT_TRUE(frame_div); - ASSERT_NO_FATAL_FAILURE(frame_div->EnsureInnerHTMLMatches("frame 2")); + ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(frame_div, "frame 2")); // Get both inner iframes, checking their contents are correct. DOMElementProxyRef iframe1 = @@ -244,10 +281,10 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, Frames) { ASSERT_TRUE(iframe1 && iframe2); frame_div = iframe1->FindElement(By::XPath("/html/body/div")); ASSERT_TRUE(frame_div); - ASSERT_NO_FATAL_FAILURE(frame_div->EnsureInnerHTMLMatches("iframe 1")); + ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(frame_div, "iframe 1")); frame_div = iframe2->FindElement(By::XPath("/html/body/div")); ASSERT_TRUE(frame_div); - ASSERT_NO_FATAL_FAILURE(frame_div->EnsureInnerHTMLMatches("iframe 2")); + ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(frame_div, "iframe 2")); // Get nested frame. ASSERT_EQ(iframe1.get(), main_doc->GetDocumentFromFrame("0", "0").get()); @@ -262,24 +299,24 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, Events) { // Click link and make sure text changes. DOMElementProxyRef link = main_doc->FindElement(By::Selectors("a")); ASSERT_TRUE(link && link->Click()); - ASSERT_NO_FATAL_FAILURE(link->EnsureTextMatches("clicked")); + ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(link, "clicked")); // Click input button and make sure textfield changes. DOMElementProxyRef button = main_doc->FindElement(By::Selectors("#button")); DOMElementProxyRef textfield = main_doc->FindElement(By::Selectors("#textfield")); ASSERT_TRUE(textfield && button && button->Click()); - ASSERT_NO_FATAL_FAILURE(textfield->EnsureTextMatches("clicked")); + ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(textfield, "clicked")); // Type in the textfield. ASSERT_TRUE(textfield->SetText("test")); - ASSERT_NO_FATAL_FAILURE(textfield->EnsureTextMatches("test")); + ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(textfield, "test")); // Type in the textarea. DOMElementProxyRef textarea = main_doc->FindElement(By::Selectors("textarea")); ASSERT_TRUE(textarea && textarea->Type("test")); - ASSERT_NO_FATAL_FAILURE(textarea->EnsureTextMatches("textareatest")); + ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(textarea, "textareatest")); } IN_PROC_BROWSER_TEST_F(DOMAutomationTest, StringEscape) { @@ -291,7 +328,7 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, StringEscape) { DOMElementProxyRef textarea = main_doc->FindElement(By::Selectors("textarea")); ASSERT_TRUE(textarea); - ASSERT_NO_FATAL_FAILURE(textarea->EnsureTextMatches(WideToUTF8(L"\u00FF"))); + ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(textarea, WideToUTF8(L"\u00FF"))); const wchar_t* set_and_expect_strings[] = { L"\u00FF and \u00FF", @@ -300,8 +337,8 @@ IN_PROC_BROWSER_TEST_F(DOMAutomationTest, StringEscape) { }; for (size_t i = 0; i < 3; i++) { ASSERT_TRUE(textarea->SetText(WideToUTF8(set_and_expect_strings[i]))); - ASSERT_NO_FATAL_FAILURE(textarea->EnsureTextMatches( - WideToUTF8(set_and_expect_strings[i]))); + ASSERT_NO_FATAL_FAILURE(EnsureTextMatches( + textarea, WideToUTF8(set_and_expect_strings[i]))); } } diff --git a/chrome/test/automation/dom_element_proxy.cc b/chrome/test/automation/dom_element_proxy.cc index 8dce073..e11a48f 100644 --- a/chrome/test/automation/dom_element_proxy.cc +++ b/chrome/test/automation/dom_element_proxy.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,7 +6,6 @@ #include "chrome/test/automation/javascript_execution_controller.h" #include "chrome/test/automation/javascript_message_utils.h" -#include "testing/gtest/include/gtest/gtest.h" using javascript_utils::JavaScriptPrintf; @@ -239,47 +238,13 @@ bool DOMElementProxy::GetVisibility(bool* visibility) { return GetValue("visibility", visibility); } -void DOMElementProxy::EnsureFindNoElements(const By& by) { - std::vector<DOMElementProxyRef> elements; - ASSERT_TRUE(FindElements(by, &elements)); - ASSERT_EQ(0u, elements.size()); -} - -void DOMElementProxy::EnsureTextMatches(const std::string& expected_text) { - std::string text; - ASSERT_TRUE(GetText(&text)); - ASSERT_EQ(expected_text, text); -} - -void DOMElementProxy::EnsureInnerHTMLMatches(const std::string& expected_html) { - std::string html; - ASSERT_TRUE(GetInnerHTML(&html)); - ASSERT_EQ(expected_html, html); -} - -void DOMElementProxy::EnsureNameMatches(const std::string& expected_name) { - std::string name; - ASSERT_TRUE(GetName(&name)); - ASSERT_EQ(expected_name, name); -} - -void DOMElementProxy::EnsureVisibilityMatches(bool expected_visibility) { - bool visibility; - ASSERT_TRUE(GetVisibility(&visibility)); - ASSERT_EQ(expected_visibility, visibility); -} - -void DOMElementProxy::EnsureAttributeEventuallyMatches( +bool DOMElementProxy::DoesAttributeEventuallyMatch( const std::string& attribute, const std::string& new_value) { - ASSERT_TRUE(is_valid()); - const char* script = "domAutomation.waitForAttribute(" "domAutomation.getObject(%s), %s, %s," "domAutomation.getCallId())"; - if (!executor_->ExecuteAsyncJavaScript( - JavaScriptPrintf(script, this->handle(), attribute, new_value))) { - FAIL() << "Executing or parsing JavaScript failed"; - } + return executor_->ExecuteAsyncJavaScript( + JavaScriptPrintf(script, this->handle(), attribute, new_value)); } template <typename T> diff --git a/chrome/test/automation/dom_element_proxy.h b/chrome/test/automation/dom_element_proxy.h index 97a0b4d..d1e1b71 100644 --- a/chrome/test/automation/dom_element_proxy.h +++ b/chrome/test/automation/dom_element_proxy.h @@ -157,27 +157,11 @@ class DOMElementProxy : public JavaScriptObjectProxy { // Retrieves the element's visibility. Returns true on success. bool GetVisibility(bool* visilibity); - // Asserts that no elements can be found by the given locator method. - void EnsureFindNoElements(const By& by); - - // Asserts that |expected_text| matches all the text in this element. This - // includes the value of textfields and inputs. - void EnsureTextMatches(const std::string& expected_text); - - // Asserts that |expected_html| matches the element's inner html. - void EnsureInnerHTMLMatches(const std::string& expected_html); - - // Asserts that |expected_name| matches the element's name. - void EnsureNameMatches(const std::string& expected_name); - - // Asserts that |expected_visibility| matches the element's visibility. - void EnsureVisibilityMatches(bool expected_visibility); - - // Asserts that |expected_value| eventually matches the element's value for + // Returns if |expected_value| eventually matches the element's value for // |attribute|. This function will block until the timeout is exceeded, in // which case it will fail, or until the two values match. - void EnsureAttributeEventuallyMatches(const std::string& attribute, - const std::string& expected_value); + bool DoesAttributeEventuallyMatch(const std::string& attribute, + const std::string& expected_value); private: // Gets the element's value for the given type. This is a helper method diff --git a/chrome/test/automation/extension_proxy.cc b/chrome/test/automation/extension_proxy.cc index 147df636..e8d14cb 100644 --- a/chrome/test/automation/extension_proxy.cc +++ b/chrome/test/automation/extension_proxy.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -8,7 +8,6 @@ #include "chrome/common/automation_messages.h" #include "chrome/test/automation/automation_proxy.h" #include "chrome/test/automation/browser_proxy.h" -#include "testing/gtest/include/gtest/gtest.h" ExtensionProxy::ExtensionProxy(AutomationMessageSender* sender, AutomationHandleTracker* tracker, @@ -100,30 +99,6 @@ bool ExtensionProxy::GetBrowserActionIndex(int* index) { return true; } -void ExtensionProxy::EnsureIdMatches(const std::string& expected_id) { - std::string id; - ASSERT_TRUE(GetId(&id)); - ASSERT_EQ(expected_id, id); -} - -void ExtensionProxy::EnsureNameMatches(const std::string& expected_name) { - std::string name; - ASSERT_TRUE(GetName(&name)); - ASSERT_EQ(expected_name, name); -} - -void ExtensionProxy::EnsureVersionMatches(const std::string& expected_version) { - std::string version; - ASSERT_TRUE(GetVersion(&version)); - ASSERT_EQ(expected_version, version); -} - -void ExtensionProxy::EnsureBrowserActionIndexMatches(int expected_index) { - int index; - ASSERT_TRUE(GetBrowserActionIndex(&index)); - ASSERT_EQ(expected_index, index); -} - bool ExtensionProxy::GetProperty(AutomationMsg_ExtensionProperty type, std::string* value) { DCHECK(value); diff --git a/chrome/test/automation/extension_proxy.h b/chrome/test/automation/extension_proxy.h index ac4d7ec..0bc7801 100644 --- a/chrome/test/automation/extension_proxy.h +++ b/chrome/test/automation/extension_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -65,19 +65,6 @@ class ExtensionProxy : public AutomationResourceProxy { // does not have a browser action in the toolbar. Returns true on success. bool GetBrowserActionIndex(int* index) WARN_UNUSED_RESULT; - // Asserts that |expected_id| matches this extension's id. - void EnsureIdMatches(const std::string& expected_id); - - // Asserts that |expected_name| matches this extension's name. - void EnsureNameMatches(const std::string& expected_name); - - // Asserts that |expected_version| matches this extension's name. - void EnsureVersionMatches(const std::string& expected_version); - - // Asserts that |expected_index| matches the index (zero-based) of this - // extension's browser action in the browser action toolbar. - void EnsureBrowserActionIndexMatches(int expected_index); - private: // Gets the string value of the property of type |type|. Returns true on // success. diff --git a/chrome/test/automation/extension_proxy_uitest.cc b/chrome/test/automation/extension_proxy_uitest.cc index 520a6de..1bc00ae 100644 --- a/chrome/test/automation/extension_proxy_uitest.cc +++ b/chrome/test/automation/extension_proxy_uitest.cc @@ -120,7 +120,13 @@ TEST_F(ExtensionProxyUITest, DISABLED_ExecuteBrowserActionInActiveTabAsync) { // the tab's index. ASSERT_TRUE(rename_tab_extension-> ExecuteActionInActiveTabAsync(browser.get())); - ASSERT_NO_FATAL_FAILURE(automation()->EnsureExtensionTestResult()); + + bool result; + std::string message; + + if (!automation()->GetExtensionTestResult(&result, &message)) + FAIL() << "Could not send WaitForExtensionTestResult message"; + ASSERT_TRUE(result) << "Extension test message: " << message; scoped_refptr<TabProxy> display_tab = browser->GetTab(0); ASSERT_TRUE(display_tab); @@ -134,7 +140,9 @@ TEST_F(ExtensionProxyUITest, DISABLED_ExecuteBrowserActionInActiveTabAsync) { ASSERT_TRUE(display_tab); ASSERT_TRUE(rename_tab_extension-> ExecuteActionInActiveTabAsync(browser.get())); - ASSERT_NO_FATAL_FAILURE(automation()->EnsureExtensionTestResult()); + if (!automation()->GetExtensionTestResult(&result, &message)) + FAIL() << "Could not send WaitForExtensionTestResult message"; + ASSERT_TRUE(result) << "Extension test message: " << message; ASSERT_TRUE(display_tab->GetTabTitle(&title_wstring)); ASSERT_STREQ(L"1", title_wstring.c_str()); @@ -144,25 +152,29 @@ TEST_F(ExtensionProxyUITest, DISABLED_ExecuteBrowserActionInActiveTabAsync) { // Flaky, http://crbug.com/59441. TEST_F(ExtensionProxyUITest, FLAKY_MoveBrowserAction) { + int action_index; + scoped_refptr<ExtensionProxy> rename_tab_extension = InstallRenameTabExtension(); ASSERT_TRUE(rename_tab_extension.get()); - ASSERT_NO_FATAL_FAILURE(simple_extension_-> - EnsureBrowserActionIndexMatches(0)); - ASSERT_NO_FATAL_FAILURE(rename_tab_extension-> - EnsureBrowserActionIndexMatches(1)); + + ASSERT_TRUE(simple_extension_->GetBrowserActionIndex(&action_index)); + ASSERT_EQ(0, action_index); + ASSERT_TRUE(rename_tab_extension->GetBrowserActionIndex(&action_index)); + ASSERT_EQ(1, action_index); // Move google translate to the end, then beginning, and verify. ASSERT_TRUE(simple_extension_->MoveBrowserAction(1)); - ASSERT_NO_FATAL_FAILURE(simple_extension_-> - EnsureBrowserActionIndexMatches(1)); - ASSERT_NO_FATAL_FAILURE(rename_tab_extension-> - EnsureBrowserActionIndexMatches(0)); + ASSERT_TRUE(simple_extension_->GetBrowserActionIndex(&action_index)); + ASSERT_EQ(1, action_index); + ASSERT_TRUE(rename_tab_extension->GetBrowserActionIndex(&action_index)); + ASSERT_EQ(0, action_index); + ASSERT_TRUE(simple_extension_->MoveBrowserAction(0)); - ASSERT_NO_FATAL_FAILURE(simple_extension_-> - EnsureBrowserActionIndexMatches(0)); - ASSERT_NO_FATAL_FAILURE(rename_tab_extension-> - EnsureBrowserActionIndexMatches(1)); + ASSERT_TRUE(simple_extension_->GetBrowserActionIndex(&action_index)); + ASSERT_EQ(0, action_index); + ASSERT_TRUE(rename_tab_extension->GetBrowserActionIndex(&action_index)); + ASSERT_EQ(1, action_index); // Try moving browser action to invalid index. ASSERT_FALSE(simple_extension_->MoveBrowserAction(-1)); @@ -171,14 +183,21 @@ TEST_F(ExtensionProxyUITest, FLAKY_MoveBrowserAction) { // Flaky, http://crbug.com/59440. TEST_F(ExtensionProxyUITest, FLAKY_GetProperty) { - ASSERT_NO_FATAL_FAILURE(simple_extension_-> - EnsureIdMatches("aiglobglfckejlcpcbdokbkbjeemfhno")); - ASSERT_NO_FATAL_FAILURE(simple_extension_-> - EnsureNameMatches("Browser Action")); - ASSERT_NO_FATAL_FAILURE(simple_extension_-> - EnsureVersionMatches("0.1.1")); - ASSERT_NO_FATAL_FAILURE(simple_extension_-> - EnsureBrowserActionIndexMatches(0)); + std::string id; + ASSERT_TRUE(simple_extension_->GetId(&id)); + ASSERT_EQ("aiglobglfckejlcpcbdokbkbjeemfhno", id); + + std::string name; + ASSERT_TRUE(simple_extension_->GetName(&name)); + ASSERT_EQ("Browser Action", name); + + std::string version; + ASSERT_TRUE(simple_extension_->GetVersion(&version)); + ASSERT_EQ("0.1.1", version); + + int browser_action_index; + ASSERT_TRUE(simple_extension_->GetBrowserActionIndex(&browser_action_index)); + ASSERT_EQ(0, browser_action_index); } } // namespace diff --git a/chrome/test/perf/startup_test.cc b/chrome/test/perf/startup_test.cc index 1cb55f6..cd1fc48 100644 --- a/chrome/test/perf/startup_test.cc +++ b/chrome/test/perf/startup_test.cc @@ -11,6 +11,7 @@ #include "base/string_util.h" #include "base/sys_info.h" #include "base/test/test_file_util.h" +#include "base/test/test_timeouts.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "chrome/common/chrome_constants.h" @@ -203,7 +204,11 @@ class StartupTest : public UIPerfTest { automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser_proxy.get()); - if (browser_proxy->GetInitialLoadTimes(&min_start, &max_stop, ×) && + if (browser_proxy->GetInitialLoadTimes( + TestTimeouts::action_max_timeout_ms(), + &min_start, + &max_stop, + ×) && !times.empty()) { ASSERT_LT(nth_timed_tab, num_tabs); ASSERT_EQ(times.size(), static_cast<size_t>(num_tabs)); |