Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / find_bar / find_bar_host_browsertest.cc
index 984829e..55a2477 100644 (file)
@@ -2,14 +2,13 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/file_util.h"
+#include "base/files/file_util.h"
 #include "base/message_loop/message_loop.h"
 #include "base/prefs/pref_service.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/common/cancelable_request.h"
 #include "chrome/browser/history/history_service.h"
 #include "chrome/browser/history/history_service_factory.h"
 #include "chrome/browser/profiles/profile.h"
@@ -26,7 +25,6 @@
 #include "chrome/browser/ui/find_bar/find_notification_details.h"
 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/test/base/find_in_page_observer.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "content/public/browser/notification_types.h"
 #include "content/public/browser/render_view_host.h"
 #include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
 #include "content/public/test/browser_test_utils.h"
-#include "net/base/net_util.h"
+#include "net/base/filename_util.h"
 #include "ui/base/accelerators/accelerator.h"
 #include "ui/events/keycodes/keyboard_codes.h"
 
 #if defined(OS_WIN)
-#include "content/public/browser/web_contents_view.h"
 #include "ui/aura/window.h"
 #include "ui/aura/window_tree_host.h"
 #endif
@@ -292,8 +288,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFormsTextAreas) {
 
 // Verify search for text within special URLs such as chrome:history,
 // chrome://downloads, data directory
-#if defined(OS_WIN)
-// Disabled due to crbug.com/175711
+#if defined(OS_WIN) || defined(OS_MACOSX)
+// Disabled due to crbug.com/175711 and http://crbug.com/419987
 #define MAYBE_SearchWithinSpecialURL \
         DISABLED_SearchWithinSpecialURL
 #else
@@ -335,10 +331,16 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_SearchWithinSpecialURL) {
                             kFwd, kIgnoreCase, NULL));
 }
 
+#if defined(OS_MACOSX)
+// Disabled due to http://crbug.com/419769.
+#define MAYBE_FindInPageSpecialURLs DISABLED_FindInPageSpecialURLs
+#else
+#define MAYBE_FindInPageSpecialURLs FindInPageSpecialURLs
+#endif
 // Verify search selection coordinates. The data file used is set-up such that
 // the text occurs on the same line, and we verify their positions by verifying
 // their relative positions.
-IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) {
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FindInPageSpecialURLs) {
   std::wstring search_string(L"\u5728\u897f\u660c\u536b\u661f\u53d1");
   gfx::Rect first, second, first_reverse;
   WebContents* web_contents =
@@ -364,9 +366,16 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) {
   ASSERT_EQ(first, first_reverse);
 }
 
+#if defined(OS_MACOSX)
+// Disabled due to http://crbug.com/419769.
+#define MAYBE_CommentsAndMetaDataNotSearchable \
+  DISABLED_CommentsAndMetaDataNotSearchable
+#else
+#define MAYBE_CommentsAndMetaDataNotSearchable CommentsAndMetaDataNotSearchable
+#endif
 // Verifies that comments and meta data are not searchable.
 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
-                       CommentsAndMetaDataNotSearchable) {
+                       MAYBE_CommentsAndMetaDataNotSearchable) {
   WebContents* web_contents =
       browser()->tab_strip_model()->GetActiveWebContents();
   ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html"));
@@ -393,7 +402,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SpanAndListsSearchable) {
 }
 
 // Find in a very large page.
-IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, LargePage) {
+// Disabled due to http://crbug.com/398017
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, DISABLED_LargePage) {
   WebContents* web_contents =
       browser()->tab_strip_model()->GetActiveWebContents();
   ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html"));
@@ -431,8 +441,14 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, BigString) {
                             kFwd, kIgnoreCase, NULL));
 }
 
+// http://crbug.com/369169
+#if defined(OS_CHROMEOS)
+#define MAYBE_SingleOccurrence DISABLED_SingleOccurrence
+#else
+#define MAYBE_SingleOccurrence SingleOccurrence
+#endif
 // Search Back and Forward on a single occurrence.
-IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SingleOccurrence) {
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_SingleOccurrence) {
   WebContents* web_contents =
       browser()->tab_strip_model()->GetActiveWebContents();
   ui_test_utils::NavigateToURL(browser(), GetURL("FindRandomTests.html"));
@@ -799,7 +815,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue1155639) {
 
 // Make sure we don't get into an infinite loop when text box contains very
 // large amount of text.
-IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue70505) {
+// Disable the test as it started being flaky, see http://crbug/367701.
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
+                       DISABLED_FindRestarts_Issue70505) {
   // First we navigate to our page.
   GURL url = GetURL(kLongTextareaPage);
   ui_test_utils::NavigateToURL(browser(), url);
@@ -833,7 +851,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
   EXPECT_EQ(1, ordinal);
 }
 
-IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
+// Verify that the find bar is hidden on reload and navigation.
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
+                       HideFindBarOnNavigateAndReload) {
   // First we navigate to our special focus tracking page.
   GURL url = GetURL(kSimple);
   GURL url2 = GetURL(kFramePage);
@@ -848,7 +868,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
   EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
   EXPECT_TRUE(fully_visible);
 
-  // Reload the tab and make sure Find window doesn't go away.
+  // Reload and make sure the find window goes away.
   content::WindowedNotificationObserver observer(
       content::NOTIFICATION_LOAD_STOP,
       content::Source<NavigationController>(
@@ -856,11 +876,17 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
               GetController()));
   chrome::Reload(browser(), CURRENT_TAB);
   observer.Wait();
+  EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
+  EXPECT_FALSE(fully_visible);
+
+  // Open the find bar again.
+  chrome::ShowFindBar(browser());
 
+  // Make sure it is open.
   EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
   EXPECT_TRUE(fully_visible);
 
-  // Navigate and make sure the Find window goes away.
+  // Navigate and make sure the find window goes away.
   ui_test_utils::NavigateToURL(browser(), url2);
 
   EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
@@ -992,9 +1018,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesWhenObscuring) {
   EXPECT_EQ(position.x(), start_position.x());
 }
 
-// FindNextInNewTabUsesPrepopulate times-out on Mac, Windows and Aura.
+// FindNextInNewTabUsesPrepopulate times-out on Mac and Aura.
 // See http://crbug.com/43070
-#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
+#if defined(OS_MACOSX) || defined(USE_AURA)
 #define MAYBE_FindNextInNewTabUsesPrepopulate \
     DISABLED_FindNextInNewTabUsesPrepopulate
 #else
@@ -1189,7 +1215,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateInNewTab) {
   EXPECT_EQ(ASCIIToUTF16("1 of 1"), GetMatchCountText());
 
   // Now create a second tab and load the same page.
-  chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED);
+  chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED);
   WebContents* web_contents_2 =
       browser()->tab_strip_model()->GetActiveWebContents();
   EXPECT_NE(web_contents_1, web_contents_2);
@@ -1314,7 +1340,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) {
       content::NOTIFICATION_LOAD_STOP,
       content::NotificationService::AllSources());
   chrome::AddSelectedTabWithURL(incognito_browser, url,
-                                content::PAGE_TRANSITION_AUTO_TOPLEVEL);
+                                ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
   observer.Wait();
   incognito_browser->window()->Show();
 
@@ -1335,7 +1361,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) {
       FindBarController::kKeepResultsInFindBox);
 
   // Now open a new tab in the original (non-incognito) browser.
-  chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED);
+  chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED);
   WebContents* web_contents_2 =
       browser()->tab_strip_model()->GetActiveWebContents();
   EXPECT_NE(web_contents_1, web_contents_2);
@@ -1369,14 +1395,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, ActivateLinkNavigatesPage) {
   observer.Wait();
 }
 
-// Tests that FindBar fits within a narrow browser window.
-// Flaky on Linux/GTK: http://crbug.com/136443.
-#if defined(TOOLKIT_GTK)
-#define MAYBE_FitWindow DISABLED_FitWindow
-#else
-#define MAYBE_FitWindow FitWindow
-#endif
-IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FitWindow) {
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) {
   Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile(),
                                browser()->host_desktop_type());
   params.initial_bounds = gfx::Rect(0, 0, 250, 500);
@@ -1384,8 +1403,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FitWindow) {
   content::WindowedNotificationObserver observer(
       content::NOTIFICATION_LOAD_STOP,
       content::NotificationService::AllSources());
-  chrome::AddSelectedTabWithURL(popup, GURL(content::kAboutBlankURL),
-                                content::PAGE_TRANSITION_LINK);
+  chrome::AddSelectedTabWithURL(
+      popup, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK);
   // Wait for the page to finish loading.
   observer.Wait();
   popup->window()->Show();
@@ -1553,74 +1572,3 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, IncognitoFindNextShared) {
   EXPECT_EQ(ASCIIToUTF16("bar"),
             GetFindBarTextForBrowser(browser_incognito));
 }
-
-#if defined(OS_WIN)
-
-BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) {
-  HWND* child = reinterpret_cast<HWND*>(l_param);
-  *child = hwnd;
-  // The first child window is the plugin, then its children. So stop
-  // enumerating after the first callback.
-  return FALSE;
-}
-
-// Ensure that the find bar is always over a windowed NPAPI plugin.
-IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, WindowedNPAPIPluginHidden) {
-  browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
-                                               true);
-
-  // First load the page and wait for the NPAPI plugin's window to display.
-  base::string16 expected_title(ASCIIToUTF16("ready"));
-  content::WebContents* tab =
-      browser()->tab_strip_model()->GetActiveWebContents();
-  content::TitleWatcher title_watcher(tab, expected_title);
-
-  GURL url = ui_test_utils::GetTestUrl(
-      base::FilePath().AppendASCII("printing"),
-      base::FilePath().AppendASCII("npapi_plugin.html"));
-  ui_test_utils::NavigateToURL(browser(), url);
-
-  EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
-
-  // Now get the region of the plugin before the find bar is shown.
-  HWND hwnd =
-      tab->GetView()->GetNativeView()->GetHost()->GetAcceleratedWidget();
-  HWND child = NULL;
-  EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child));
-
-  RECT region_before, region_after;
-  int result = GetWindowRgnBox(child, &region_before);
-  ASSERT_EQ(result, SIMPLEREGION);
-
-  // Create a new tab and open the find bar there.
-  chrome::NewTab(browser());
-  browser()->tab_strip_model()->ActivateTabAt(1, true);
-  ui_test_utils::NavigateToURL(browser(), GURL(content::kAboutBlankURL));
-
-  EnsureFindBoxOpen();
-
-  // Now switch back to the original tab with the plugin and show the find bar.
-  browser()->tab_strip_model()->ActivateTabAt(0, true);
-  EnsureFindBoxOpen();
-
-  result = GetWindowRgnBox(child, &region_after);
-  if (result == NULLREGION) {
-    // Depending on the browser window size, the plugin could be full covered.
-    return;
-  }
-
-  if (result == COMPLEXREGION) {
-    // Complex region, by definition not equal to the initial region.
-    return;
-  }
-
-  ASSERT_EQ(result, SIMPLEREGION);
-  bool rects_equal =
-      region_before.left == region_after.left &&
-      region_before.top == region_after.top &&
-      region_before.right == region_after.right &&
-      region_before.bottom == region_after.bottom;
-  ASSERT_FALSE(rects_equal);
-}
-
-#endif