summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/tree_node_model.h7
-rw-r--r--chrome/browser/browser_focus_uitest.cc23
-rw-r--r--chrome/browser/browser_keyevents_browsertest.cc14
-rw-r--r--chrome/browser/views/find_bar_host_interactive_uitest.cc10
-rw-r--r--chrome/browser/views/tabs/tab_dragging_test.cc122
-rw-r--r--chrome/test/interactive_ui/interactive_ui_tests.gypi19
-rw-r--r--chrome/test/interactive_ui/view_event_test_base.cc5
-rw-r--r--chrome/test/ui_test_utils_linux.cc14
8 files changed, 145 insertions, 69 deletions
diff --git a/app/tree_node_model.h b/app/tree_node_model.h
index 0d9f2b9..b11bf38 100644
--- a/app/tree_node_model.h
+++ b/app/tree_node_model.h
@@ -82,7 +82,9 @@ class TreeNode : public TreeModelNode {
// Adds the specified child node.
virtual void Add(int index, NodeType* child) {
- DCHECK(child && index >= 0 && index <= GetChildCount());
+ DCHECK(child);
+ DCHECK_LE(0, index);
+ DCHECK_GE(GetChildCount(), index);
// If the node has a parent, remove it from its parent.
NodeType* node_parent = child->GetParent();
if (node_parent)
@@ -130,7 +132,8 @@ class TreeNode : public TreeModelNode {
return children_[index];
}
const NodeType* GetChild(int index) const {
- DCHECK(index >= 0 && index < GetChildCount());
+ DCHECK_LE(0, index);
+ DCHECK_GT(GetChildCount(), index);
return children_[index];
}
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 47bace1..77008e8 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -4,6 +4,7 @@
#include "build/build_config.h"
+#include "base/format_macros.h"
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "chrome/browser/automation/ui_controls.h"
@@ -401,7 +402,9 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) {
focused_browser->window()->Activate();
// Wait for the focus to be stolen by the other browser.
- PlatformThread::Sleep(2000);
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, new MessageLoop::QuitTask(), 2000);
+ ui_test_utils::RunMessageLoop();
// Make sure the first browser is still active.
EXPECT_TRUE(focused_browser->window()->IsActive());
@@ -452,11 +455,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) {
// Test forward focus traversal.
for (int i = 0; i < 3; ++i) {
+ SCOPED_TRACE(StringPrintf("outer loop: %d", i));
// Location bar should be focused.
ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
// Now let's press tab to move the focus.
for (size_t j = 0; j < arraysize(kExpElementIDs); ++j) {
+ SCOPED_TRACE(StringPrintf("inner loop %" PRIuS, j));
// Let's make sure the focus is on the expected element in the page.
std::string actual;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
@@ -481,16 +486,18 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) {
// At this point the renderer has sent us a message asking to advance the
// focus (as the end of the focus loop was reached in the renderer).
// We need to run the message loop to process it.
- MessageLoop::current()->RunAllPending();
+ ui_test_utils::RunAllPendingInMessageLoop();
}
// Now let's try reverse focus traversal.
for (int i = 0; i < 3; ++i) {
+ SCOPED_TRACE(StringPrintf("outer loop: %d", i));
// Location bar should be focused.
ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
// Now let's press shift-tab to move the focus in reverse.
for (size_t j = 0; j < 7; ++j) {
+ SCOPED_TRACE(StringPrintf("inner loop: %" PRIuS, j));
ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB,
false, true, false));
@@ -515,7 +522,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) {
// At this point the renderer has sent us a message asking to advance the
// focus (as the end of the focus loop was reached in the renderer).
// We need to run the message loop to process it.
- MessageLoop::current()->RunAllPending();
+ ui_test_utils::RunAllPendingInMessageLoop();
}
}
@@ -577,7 +584,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
// At this point the renderer has sent us a message asking to advance the
// focus (as the end of the focus loop was reached in the renderer).
// We need to run the message loop to process it.
- MessageLoop::current()->RunAllPending();
+ ui_test_utils::RunAllPendingInMessageLoop();
}
// Now let's try reverse focus traversal.
@@ -605,7 +612,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
// At this point the renderer has sent us a message asking to advance the
// focus (as the end of the focus loop was reached in the renderer).
// We need to run the message loop to process it.
- MessageLoop::current()->RunAllPending();
+ ui_test_utils::RunAllPendingInMessageLoop();
}
}
@@ -702,6 +709,9 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) {
// Open the history tab, focus should be on the tab contents.
browser()->ShowHistoryTab();
+
+ ui_test_utils::RunAllPendingInMessageLoop();
+
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
// Open the new tab, focus should be on the location bar.
@@ -724,6 +734,9 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
// Open the new tab, reload.
browser()->NewTab();
+
+ ui_test_utils::RunAllPendingInMessageLoop();
+
browser()->Reload();
ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
// Focus should stay on the location bar.
diff --git a/chrome/browser/browser_keyevents_browsertest.cc b/chrome/browser/browser_keyevents_browsertest.cc
index cf23cba..e7c9ba0 100644
--- a/chrome/browser/browser_keyevents_browsertest.cc
+++ b/chrome/browser/browser_keyevents_browsertest.cc
@@ -134,8 +134,8 @@ class BrowserKeyEventsTest : public InProcessBrowserTest {
void SendKey(base::KeyboardCode key, bool control, bool shift, bool alt) {
gfx::NativeWindow window = NULL;
ASSERT_NO_FATAL_FAILURE(GetNativeWindow(&window));
- ui_controls::SendKeyPressNotifyWhenDone(window, key, control, shift, alt,
- new MessageLoop::QuitTask());
+ EXPECT_TRUE(ui_controls::SendKeyPressNotifyWhenDone(
+ window, key, control, shift, alt, new MessageLoop::QuitTask()));
ui_test_utils::RunMessageLoop();
}
@@ -447,7 +447,14 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, CtrlKeyEvents) {
EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlEnter));
}
-IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, AccessKeys) {
+#if defined(OS_CHROMEOS)
+// See http://crbug.com/40037 for details.
+#define MAYBE_AccessKeys DISABLED_AccessKeys
+#else
+#define MAYBE_AccessKeys AccessKeys
+#endif
+
+IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, MAYBE_AccessKeys) {
static const KeyEventTestData kTestAltA = {
base::VKEY_A, false, false, true,
false, false, false, false, 4,
@@ -487,6 +494,7 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, AccessKeys) {
GURL url = server->TestServerPageW(kTestingPage);
ui_test_utils::NavigateToURL(browser(), url);
+ ui_test_utils::RunAllPendingInMessageLoop();
ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER));
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
diff --git a/chrome/browser/views/find_bar_host_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc
index 0b66cc9..e0819e6 100644
--- a/chrome/browser/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/views/find_bar_host_interactive_uitest.cc
@@ -53,9 +53,17 @@ class FindInPageTest : public InProcessBrowserTest {
int GetFocusedViewID() {
#if defined(TOOLKIT_VIEWS)
+#if defined(OS_LINUX)
+ // See http://crbug.com/26873 .
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(
+ GTK_WIDGET(browser()->window()->GetNativeHandle()));
+#else
views::FocusManager* focus_manager =
views::FocusManager::GetFocusManagerForNativeView(
browser()->window()->GetNativeHandle());
+#endif
+
if (!focus_manager) {
NOTREACHED();
return -1;
@@ -135,7 +143,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
browser()->Find();
EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID());
ui_test_utils::FindInPage(browser()->GetSelectedTabContents(),
- L"a", true, false, NULL);
+ ASCIIToUTF16("a"), true, false, NULL);
browser()->GetFindBarController()->EndFindSession(
FindBarController::kKeepSelection);
EXPECT_EQ(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW, GetFocusedViewID());
diff --git a/chrome/browser/views/tabs/tab_dragging_test.cc b/chrome/browser/views/tabs/tab_dragging_test.cc
index 0fb56ce..f7f3d0b 100644
--- a/chrome/browser/views/tabs/tab_dragging_test.cc
+++ b/chrome/browser/views/tabs/tab_dragging_test.cc
@@ -18,6 +18,19 @@
#include "net/base/net_util.h"
#include "views/event.h"
+#if defined(OS_CHROMEOS)
+// Disabled, see http://crbug.com/40043.
+#define MAYBE_Tab2OutOfTabStrip DISABLED_Tab2OutOfTabStrip
+#define MAYBE_Tab1Tab3Escape DISABLED_Tab1Tab3Escape
+
+#else
+#define MAYBE_Tab2OutOfTabStrip Tab2OutOfTabStrip
+
+// Flaky, see http://crbug.com/21092.
+#define MAYBE_Tab1Tab3Escape FLAKY_Tab1Tab3Escape
+
+#endif
+
class TabDraggingTest : public UITest {
protected:
@@ -92,16 +105,18 @@ TEST_F(TabDraggingTest, DISABLED_Tab1Tab2) {
EXPECT_LT(0, urlbar_bounds.width());
EXPECT_LT(0, urlbar_bounds.height());
- // TEST: Move Tab_1 to the position of Tab_2
- // ____________ ____________ ____________
- // / \ / \ / \
- // | Tab_1 | Tab_2 | Tab_3 |
- // ---- ---- ---- ---- ---- ---- ---- ---- ----
- // x---- ---->
- // ____________
- // / X \
- // | Tab_1 |
- // ---- ---- ----
+ /*
+ TEST: Move Tab_1 to the position of Tab_2
+ ____________ ____________ ____________
+ / \ / \ / \
+ | Tab_1 | Tab_2 | Tab_3 |
+ ---- ---- ---- ---- ---- ---- ---- ---- ----
+ x---- ---->
+ ____________
+ / X \
+ | Tab_1 |
+ ---- ---- ----
+ */
gfx::Point start(bounds1.x() + bounds1.width() / 2,
bounds1.y() + bounds1.height() / 2);
@@ -190,16 +205,18 @@ TEST_F(TabDraggingTest, DISABLED_Tab1Tab3) {
EXPECT_LT(0, urlbar_bounds.width());
EXPECT_LT(0, urlbar_bounds.height());
- // TEST: Move Tab_1 to the middle position of Tab_3
- // ____________ ____________ ____________
- // / \ / \ / \
- // | Tab_1 | Tab_2 | Tab_3 |
- // ---- ---- ---- ---- ---- ---- ---- ---- ----
- // x---- ---- ---- ---- ---- ---->
- // ____________
- // / X \
- // | Tab_1 |
- // ---- ---- ----
+ /*
+ TEST: Move Tab_1 to the middle position of Tab_3
+ ____________ ____________ ____________
+ / \ / \ / \
+ | Tab_1 | Tab_2 | Tab_3 |
+ ---- ---- ---- ---- ---- ---- ---- ---- ----
+ x---- ---- ---- ---- ---- ---->
+ ____________
+ / X \
+ | Tab_1 |
+ ---- ---- ----
+ */
gfx::Point start(bounds1.x() + bounds1.width() / 2,
bounds1.y() + bounds1.height() / 2);
@@ -233,8 +250,7 @@ TEST_F(TabDraggingTest, DISABLED_Tab1Tab3) {
// Drag Tab_1 into the position of Tab_3, and press ESCAPE before releasing the
// left mouse button.
-// Flaky, see http://crbug.com/21092.
-TEST_F(TabDraggingTest, FLAKY_Tab1Tab3Escape) {
+TEST_F(TabDraggingTest, MAYBE_Tab1Tab3Escape) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
ASSERT_TRUE(browser.get());
scoped_refptr<WindowProxy> window(browser->GetWindow());
@@ -297,16 +313,18 @@ TEST_F(TabDraggingTest, FLAKY_Tab1Tab3Escape) {
EXPECT_LT(0, urlbar_bounds.width());
EXPECT_LT(0, urlbar_bounds.height());
- // TEST: Move Tab_1 to the middle position of Tab_3
- // ____________ ____________ ____________
- // / \ / \ / \
- // | Tab_1 | Tab_2 | Tab_3 |
- // ---- ---- ---- ---- ---- ---- ---- ---- ----
- // x---- ---- ---- ---- ---- ----> + ESCAPE
- // ____________
- // / X \
- // | Tab_1 |
- // ---- ---- ----
+ /*
+ TEST: Move Tab_1 to the middle position of Tab_3
+ ____________ ____________ ____________
+ / \ / \ / \
+ | Tab_1 | Tab_2 | Tab_3 |
+ ---- ---- ---- ---- ---- ---- ---- ---- ----
+ x---- ---- ---- ---- ---- ----> + ESCAPE
+ ____________
+ / X \
+ | Tab_1 |
+ ---- ---- ----
+ */
gfx::Point start(bounds1.x() + bounds1.width() / 2,
bounds1.y() + bounds1.height() / 2);
@@ -343,7 +361,7 @@ TEST_F(TabDraggingTest, FLAKY_Tab1Tab3Escape) {
}
// Drag Tab_2 out of the Tab strip. A new window should open with this tab.
-TEST_F(TabDraggingTest, Tab2OutOfTabStrip) {
+TEST_F(TabDraggingTest, MAYBE_Tab2OutOfTabStrip) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
ASSERT_TRUE(browser.get());
scoped_refptr<WindowProxy> window(browser->GetWindow());
@@ -411,24 +429,26 @@ TEST_F(TabDraggingTest, Tab2OutOfTabStrip) {
EXPECT_LT(0, urlbar_bounds.width());
EXPECT_LT(0, urlbar_bounds.height());
- // TEST: Move Tab_2 down, out of the tab strip.
- // This should result in the following:
- // 1- Tab_3 shift left in place of Tab_2 in Window 1
- // 2- Tab_1 to remain in its place
- // 3- Tab_2 openes in a new window
- //
- // ____________ ____________ ____________
- // / \ / \ / \
- // | Tab_1 | Tab_2 | Tab_3 |
- // ---- ---- ---- ---- ---- ---- ---- ---- ----
- // x
- // |
- // | (Drag this below, out of tab strip)
- // V
- // ____________
- // / X \
- // | Tab_2 | (New Window)
- // ---- ---- ---- ---- ---- ---- ----
+ /*
+ TEST: Move Tab_2 down, out of the tab strip.
+ This should result in the following:
+ 1- Tab_3 shift left in place of Tab_2 in Window 1
+ 2- Tab_1 to remain in its place
+ 3- Tab_2 openes in a new window
+
+ ____________ ____________ ____________
+ / \ / \ / \
+ | Tab_1 | Tab_2 | Tab_3 |
+ ---- ---- ---- ---- ---- ---- ---- ---- ----
+ x
+ |
+ | (Drag this below, out of tab strip)
+ V
+ ____________
+ / X \
+ | Tab_2 | (New Window)
+ ---- ---- ---- ---- ---- ---- ----
+ */
gfx::Point start(bounds2.x() + bounds2.width() / 2,
bounds2.y() + bounds2.height() / 2);
diff --git a/chrome/test/interactive_ui/interactive_ui_tests.gypi b/chrome/test/interactive_ui/interactive_ui_tests.gypi
index f14b88d..603b7fa 100644
--- a/chrome/test/interactive_ui/interactive_ui_tests.gypi
+++ b/chrome/test/interactive_ui/interactive_ui_tests.gypi
@@ -48,7 +48,7 @@
'<(DEPTH)/chrome/test/unit/chrome_test_suite.h',
],
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" and toolkit_views==0 and chromeos==0', {
'dependencies': [
'<(DEPTH)/build/linux/system.gyp:gtk',
'<(DEPTH)/tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
@@ -63,17 +63,24 @@
'<(DEPTH)/chrome/test/interactive_ui/view_event_test_base.h',
],
}], # OS=="linux"
+ ['OS=="linux" and (toolkit_views==1 or chromeos==1)', {
+ 'dependencies': [
+ '<(DEPTH)/build/linux/system.gyp:gtk',
+ '<(DEPTH)/tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
+ '<(DEPTH)/views/views.gyp:views',
+ ],
+ 'sources!': [
+ '<(DEPTH)/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc',
+ # TODO(port)
+ '<(DEPTH)/chrome/test/interactive_ui/npapi_interactive_test.cc',
+ ],
+ }], # OS=="linux" and (toolkit_views==1 or chromeos==1)
['target_arch!="x64" and target_arch!="arm"', {
'dependencies': [
# run time dependency
'<(DEPTH)/webkit/webkit.gyp:npapi_test_plugin',
],
}], # target_arch
- ['OS=="linux" and (toolkit_views==1 or chromeos==1)', {
- 'dependencies': [
- '<(DEPTH)/views/views.gyp:views',
- ],
- }],
['OS=="mac"', {
'sources!': [
# TODO(port)
diff --git a/chrome/test/interactive_ui/view_event_test_base.cc b/chrome/test/interactive_ui/view_event_test_base.cc
index e971954..8936d57 100644
--- a/chrome/test/interactive_ui/view_event_test_base.cc
+++ b/chrome/test/interactive_ui/view_event_test_base.cc
@@ -12,6 +12,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "chrome/browser/automation/ui_controls.h"
+#include "chrome/test/ui_test_utils.h"
#include "views/view.h"
#include "views/window/window.h"
@@ -87,7 +88,9 @@ void ViewEventTestBase::TearDown() {
#if defined(OS_WIN)
DestroyWindow(window_->GetNativeWindow());
#else
- gtk_widget_destroy(GTK_WIDGET(window_->GetNativeWindow()));
+ window_->Close();
+ MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
+ ui_test_utils::RunMessageLoop();
#endif
window_ = NULL;
}
diff --git a/chrome/test/ui_test_utils_linux.cc b/chrome/test/ui_test_utils_linux.cc
index ddcd1b8..5878086 100644
--- a/chrome/test/ui_test_utils_linux.cc
+++ b/chrome/test/ui_test_utils_linux.cc
@@ -13,12 +13,14 @@
#include "chrome/browser/automation/ui_controls.h"
#if defined(TOOLKIT_VIEWS)
#include "chrome/browser/views/frame/browser_view.h"
+#include "views/focus/focus_manager.h"
#endif
#include "chrome/browser/gtk/view_id_util.h"
namespace ui_test_utils {
+#if !defined(TOOLKIT_VIEWS)
namespace {
// Check if the focused widget for |root| is |target| or a child of |target|.
@@ -39,15 +41,27 @@ static bool IsWidgetInFocusChain(GtkWidget* root, GtkWidget* target) {
}
} // namespace
+#endif
bool IsViewFocused(const Browser* browser, ViewID vid) {
BrowserWindow* browser_window = browser->window();
DCHECK(browser_window);
+#if defined(TOOLKIT_VIEWS)
+ gfx::NativeWindow window = browser_window->GetNativeHandle();
+ DCHECK(window);
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(
+ GTK_WIDGET(window));
+ DCHECK(focus_manager);
+ return focus_manager->GetFocusedView() &&
+ focus_manager->GetFocusedView()->GetID() == vid;
+#else
gfx::NativeWindow window = browser_window->GetNativeHandle();
DCHECK(window);
GtkWidget* widget = ViewIDUtil::GetWidget(GTK_WIDGET(window), vid);
DCHECK(widget);
return IsWidgetInFocusChain(GTK_WIDGET(window), widget);
+#endif
}
void ClickOnView(const Browser* browser, ViewID vid) {