OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ | 5 #ifndef CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ |
6 #define CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ | 6 #define CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 // Returns true if the title of the page rendered in the window |arg| equals | 38 // Returns true if the title of the page rendered in the window |arg| equals |
39 // |the_url| or |the_title|. For pages rendered in Chrome, the title of the | 39 // |the_url| or |the_title|. For pages rendered in Chrome, the title of the |
40 // parent of |arg| is the page url or title. For pages rendered in IE, the title | 40 // parent of |arg| is the page url or title. For pages rendered in IE, the title |
41 // of the grandparent of |arg| begins with the page url or title. To handle both | 41 // of the grandparent of |arg| begins with the page url or title. To handle both |
42 // cases, attempt a prefix match on each window starting with the parent of | 42 // cases, attempt a prefix match on each window starting with the parent of |
43 // |arg|. Both url and title are matched to account for a race between the test | 43 // |arg|. Both url and title are matched to account for a race between the test |
44 // and Chrome when the window title is transitioned from the url to the title. | 44 // and Chrome when the window title is transitioned from the url to the title. |
45 MATCHER_P2(TabContentsTitleEq, the_url, the_title, "") { | 45 MATCHER_P2(TabContentsTitleEq, the_url, the_title, "") { |
46 const string16 url(the_url); | 46 const base::string16 url(the_url); |
47 DCHECK(!url.empty()); | 47 DCHECK(!url.empty()); |
48 const string16 title(the_title); | 48 const base::string16 title(the_title); |
49 DCHECK(!title.empty()); | 49 DCHECK(!title.empty()); |
50 HWND parent = GetParent(arg); | 50 HWND parent = GetParent(arg); |
51 if (parent != NULL) { | 51 if (parent != NULL) { |
52 string16 parent_title(255, L'\0'); | 52 base::string16 parent_title(255, L'\0'); |
53 std::ostringstream titles_found(std::string("titles found: ")); | 53 std::ostringstream titles_found(std::string("titles found: ")); |
54 string16 first_title; | 54 base::string16 first_title; |
55 do { | 55 do { |
56 parent_title.resize(255, L'\0'); | 56 parent_title.resize(255, L'\0'); |
57 parent_title.resize(GetWindowText(parent, &parent_title[0], | 57 parent_title.resize(GetWindowText(parent, &parent_title[0], |
58 parent_title.size())); | 58 parent_title.size())); |
59 if (parent_title.size() >= title.size() && | 59 if (parent_title.size() >= title.size() && |
60 std::equal(title.begin(), title.end(), parent_title.begin()) || | 60 std::equal(title.begin(), title.end(), parent_title.begin()) || |
61 parent_title.size() >= url.size() && | 61 parent_title.size() >= url.size() && |
62 std::equal(url.begin(), url.end(), parent_title.begin())) { | 62 std::equal(url.begin(), url.end(), parent_title.begin())) { |
63 return true; | 63 return true; |
64 } | 64 } |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 447 |
448 loop->PostDelayedTask( | 448 loop->PostDelayedTask( |
449 FROM_HERE, | 449 FROM_HERE, |
450 base::Bind(simulate_input::SendCharA, VK_RETURN, simulate_input::NONE), | 450 base::Bind(simulate_input::SendCharA, VK_RETURN, simulate_input::NONE), |
451 next_delay); | 451 next_delay); |
452 } | 452 } |
453 | 453 |
454 } // namespace chrome_frame_test | 454 } // namespace chrome_frame_test |
455 | 455 |
456 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ | 456 #endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ |
OLD | NEW |