OLD | NEW |
| (Empty) |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/app/chrome_dll_resource.h" | |
6 #include "chrome/test/automation/browser_proxy.h" | |
7 #include "chrome/test/automation/tab_proxy.h" | |
8 #include "chrome/test/ui/ui_test.h" | |
9 #include "net/url_request/url_request_unittest.h" | |
10 | |
11 class FindInPageControllerTest : public UITest { | |
12 public: | |
13 FindInPageControllerTest() { | |
14 show_window_ = true; | |
15 } | |
16 }; | |
17 | |
18 const std::wstring kSimplePage = L"404_is_enough_for_us.html"; | |
19 | |
20 // The find window should not change its location just because we open and close | |
21 // a new tab. | |
22 TEST_F(FindInPageControllerTest, FindMovesOnTabClose_Issue1343052) { | |
23 scoped_refptr<HTTPTestServer> server = | |
24 HTTPTestServer::CreateServer(L"chrome/test/data", NULL); | |
25 ASSERT_TRUE(NULL != server.get()); | |
26 | |
27 GURL url = server->TestServerPageW(kSimplePage); | |
28 scoped_refptr<TabProxy> tabA(GetActiveTab()); | |
29 ASSERT_TRUE(tabA.get()); | |
30 ASSERT_TRUE(tabA->NavigateToURL(url)); | |
31 WaitUntilTabCount(1); | |
32 | |
33 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
34 ASSERT_TRUE(browser.get() != NULL); | |
35 | |
36 // Toggle the bookmark bar state. | |
37 browser->ApplyAccelerator(IDC_SHOW_BOOKMARK_BAR); | |
38 EXPECT_TRUE(WaitForBookmarkBarVisibilityChange(browser.get(), true)); | |
39 | |
40 // Open the Find window and wait for it to animate. | |
41 EXPECT_TRUE(browser->OpenFindInPage()); | |
42 EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), true)); | |
43 | |
44 // Find its location. | |
45 int x = -1, y = -1; | |
46 EXPECT_TRUE(browser->GetFindWindowLocation(&x, &y)); | |
47 | |
48 // Open another tab (tab B). | |
49 EXPECT_TRUE(browser->AppendTab(url)); | |
50 scoped_refptr<TabProxy> tabB(GetActiveTab()); | |
51 ASSERT_TRUE(tabB.get()); | |
52 | |
53 // Close tab B. | |
54 EXPECT_TRUE(tabB->Close(true)); | |
55 | |
56 // See if the Find window has moved. | |
57 int new_x = -1, new_y = -1; | |
58 EXPECT_TRUE(browser->GetFindWindowLocation(&new_x, &new_y)); | |
59 | |
60 EXPECT_EQ(x, new_x); | |
61 EXPECT_EQ(y, new_y); | |
62 | |
63 // Now reset the bookmark bar state and try the same again. | |
64 browser->ApplyAccelerator(IDC_SHOW_BOOKMARK_BAR); | |
65 EXPECT_TRUE(WaitForBookmarkBarVisibilityChange(browser.get(), false)); | |
66 | |
67 // Bookmark bar has moved, reset our coordinates. | |
68 EXPECT_TRUE(browser->GetFindWindowLocation(&x, &y)); | |
69 | |
70 // Open another tab (tab C). | |
71 EXPECT_TRUE(browser->AppendTab(url)); | |
72 scoped_refptr<TabProxy> tabC(GetActiveTab()); | |
73 ASSERT_TRUE(tabC.get()); | |
74 | |
75 // Close it. | |
76 EXPECT_TRUE(tabC->Close(true)); | |
77 | |
78 // See if the Find window has moved. | |
79 EXPECT_TRUE(browser->GetFindWindowLocation(&new_x, &new_y)); | |
80 | |
81 EXPECT_EQ(x, new_x); | |
82 EXPECT_EQ(y, new_y); | |
83 } | |
OLD | NEW |