OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 #include "chrome/browser/view_ids.h" | 6 #include "chrome/browser/view_ids.h" |
7 #include "chrome/test/automation/browser_proxy.h" | 7 #include "chrome/test/automation/browser_proxy.h" |
8 #include "chrome/test/automation/window_proxy.h" | 8 #include "chrome/test/automation/window_proxy.h" |
9 #include "chrome/test/automation/tab_proxy.h" | 9 #include "chrome/test/automation/tab_proxy.h" |
10 #include "chrome/test/ui/ui_test.h" | 10 #include "chrome/test/ui/ui_test.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return true; | 49 return true; |
50 } | 50 } |
51 | 51 |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 TEST_F(FindInPageTest, CrashEscHandlers) { | 54 TEST_F(FindInPageTest, CrashEscHandlers) { |
55 scoped_refptr<HTTPTestServer> server = | 55 scoped_refptr<HTTPTestServer> server = |
56 HTTPTestServer::CreateServer(kDocRoot, NULL); | 56 HTTPTestServer::CreateServer(kDocRoot, NULL); |
57 ASSERT_TRUE(NULL != server.get()); | 57 ASSERT_TRUE(NULL != server.get()); |
58 | 58 |
59 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 59 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
60 ASSERT_TRUE(browser.get() != NULL); | 60 ASSERT_TRUE(browser.get() != NULL); |
61 scoped_ptr<WindowProxy> window(browser->GetWindow()); | 61 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
62 ASSERT_TRUE(window.get() != NULL); | 62 ASSERT_TRUE(window.get() != NULL); |
63 | 63 |
64 // First we navigate to our test page (tab A). | 64 // First we navigate to our test page (tab A). |
65 GURL url = server->TestServerPageW(kSimplePage); | 65 GURL url = server->TestServerPageW(kSimplePage); |
66 scoped_ptr<TabProxy> tabA(GetActiveTab()); | 66 scoped_refptr<TabProxy> tabA(GetActiveTab()); |
67 EXPECT_NE(AUTOMATION_MSG_NAVIGATION_ERROR, tabA->NavigateToURL(url)); | 67 EXPECT_NE(AUTOMATION_MSG_NAVIGATION_ERROR, tabA->NavigateToURL(url)); |
68 | 68 |
69 EXPECT_TRUE(browser->OpenFindInPage()); | 69 EXPECT_TRUE(browser->OpenFindInPage()); |
70 | 70 |
71 // Open another tab (tab B). | 71 // Open another tab (tab B). |
72 EXPECT_TRUE(browser->AppendTab(url)); | 72 EXPECT_TRUE(browser->AppendTab(url)); |
73 scoped_ptr<TabProxy> tabB(GetActiveTab()); | 73 scoped_refptr<TabProxy> tabB(GetActiveTab()); |
74 | 74 |
75 EXPECT_TRUE(browser->OpenFindInPage()); | 75 EXPECT_TRUE(browser->OpenFindInPage()); |
76 | 76 |
77 // Select tab A. | 77 // Select tab A. |
78 EXPECT_TRUE(ActivateTabByClick(automation(), window.get(), 0)); | 78 EXPECT_TRUE(ActivateTabByClick(automation(), window.get(), 0)); |
79 | 79 |
80 // Close tab B. | 80 // Close tab B. |
81 EXPECT_TRUE(tabB->Close(true)); | 81 EXPECT_TRUE(tabB->Close(true)); |
82 | 82 |
83 // Click on the location bar so that Find box loses focus. | 83 // Click on the location bar so that Find box loses focus. |
84 gfx::Rect bounds; | 84 gfx::Rect bounds; |
85 EXPECT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &bounds, false)); | 85 EXPECT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &bounds, false)); |
86 POINT click(bounds.CenterPoint().ToPOINT()); | 86 POINT click(bounds.CenterPoint().ToPOINT()); |
87 EXPECT_TRUE(window->SimulateOSClick(click, | 87 EXPECT_TRUE(window->SimulateOSClick(click, |
88 views::Event::EF_LEFT_BUTTON_DOWN)); | 88 views::Event::EF_LEFT_BUTTON_DOWN)); |
89 ::Sleep(kActionDelayMs); | 89 ::Sleep(kActionDelayMs); |
90 int focused_view_id; | 90 int focused_view_id; |
91 EXPECT_TRUE(window->GetFocusedViewID(&focused_view_id)); | 91 EXPECT_TRUE(window->GetFocusedViewID(&focused_view_id)); |
92 EXPECT_EQ(VIEW_ID_LOCATION_BAR, focused_view_id); | 92 EXPECT_EQ(VIEW_ID_LOCATION_BAR, focused_view_id); |
93 | 93 |
94 // This used to crash until bug 1303709 was fixed. | 94 // This used to crash until bug 1303709 was fixed. |
95 EXPECT_TRUE(window->SimulateOSKeyPress(VK_ESCAPE, 0)); | 95 EXPECT_TRUE(window->SimulateOSKeyPress(VK_ESCAPE, 0)); |
96 ::Sleep(kActionDelayMs); | 96 ::Sleep(kActionDelayMs); |
97 } | 97 } |
OLD | NEW |