Enable interactive_ui_tests

 * changed DCHECK in tree_node_model to make it easy to find how it failed.
 * Fixed compilation error in find_bar_host_interactive_uitest.cc on linux/views.
 * Disabled BrowserKeyEventsTest.AccessKeys for Chromeos
   Added/Changed ui_test_utils::RunAllPendingInMessageLoop where necessary.
 * Disabled tab_dragging_tests. I included the source so that we can catch
   compilation error even if tests do not run. Changed the comment from // -> /*
   as GCC complains the use of "\" (and potentially dangerous)
 * Added SleepInMessageLoop to allow event loop to execute the tasks/events
   while waiting.
 * For RunAllPendingInMessageLoop change, please see
   http://codereview.chromium.org/1591004

BUG=39736
TEST=interactive_ui_tests should pass with following cls
http://codereview.chromium.org/1594003
http://codereview.chromium.org/1545011.

Review URL: http://codereview.chromium.org/1576008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43701 0039d316-1c4b-4281-b951-d872f2087c98
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 @@
   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 @@
 
   // 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 @@
     // 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 @@
     // 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 @@
     // 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 @@
     // 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, 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 @@
 
   // 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.