OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/views/html_dialog_view.h" | 10 #include "chrome/browser/ui/views/html_dialog_view.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; } | 61 virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; } |
62 }; | 62 }; |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 class HtmlDialogBrowserTest : public InProcessBrowserTest { | 66 class HtmlDialogBrowserTest : public InProcessBrowserTest { |
67 public: | 67 public: |
68 HtmlDialogBrowserTest() {} | 68 HtmlDialogBrowserTest() {} |
69 | 69 |
70 #if defined(OS_WIN) | |
71 class WindowChangedObserver : public MessageLoopForUI::Observer { | 70 class WindowChangedObserver : public MessageLoopForUI::Observer { |
72 public: | 71 public: |
73 WindowChangedObserver() {} | 72 WindowChangedObserver() {} |
74 | 73 |
75 static WindowChangedObserver* GetInstance() { | 74 static WindowChangedObserver* GetInstance() { |
76 return Singleton<WindowChangedObserver>::get(); | 75 return Singleton<WindowChangedObserver>::get(); |
77 } | 76 } |
78 | 77 |
| 78 #if defined(OS_WIN) |
79 // This method is called before processing a message. | 79 // This method is called before processing a message. |
80 virtual void WillProcessMessage(const MSG& msg) {} | 80 virtual base::EventStatus WillProcessEvent( |
| 81 const base::NativeEvent& event) OVERRIDE { |
| 82 return base::EVENT_CONTINUE; |
| 83 } |
81 | 84 |
82 // This method is called after processing a message. | 85 // This method is called after processing a message. |
83 virtual void DidProcessMessage(const MSG& msg) { | 86 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { |
84 // Either WM_PAINT or WM_TIMER indicates the actual work of | 87 // Either WM_PAINT or WM_TIMER indicates the actual work of |
85 // pushing through the window resizing messages is done since | 88 // pushing through the window resizing messages is done since |
86 // they are lower priority (we don't get to see the | 89 // they are lower priority (we don't get to see the |
87 // WM_WINDOWPOSCHANGED message here). | 90 // WM_WINDOWPOSCHANGED message here). |
88 if (msg.message == WM_PAINT || msg.message == WM_TIMER) | 91 if (event.message == WM_PAINT || event.message == WM_TIMER) |
89 MessageLoop::current()->Quit(); | 92 MessageLoop::current()->Quit(); |
90 } | 93 } |
91 }; | 94 #elif defined(TOUCH_UI) || defined(USE_AURA) |
92 #elif !defined(OS_MACOSX) | 95 // This method is called before processing a message. |
93 class WindowChangedObserver : public MessageLoopForUI::Observer { | 96 virtual base::EventStatus WillProcessEvent( |
94 public: | 97 const base::NativeEvent& event) OVERRIDE { |
95 WindowChangedObserver() {} | 98 return base::EVENT_CONTINUE; |
96 | |
97 static WindowChangedObserver* GetInstance() { | |
98 return Singleton<WindowChangedObserver>::get(); | |
99 } | 99 } |
100 | 100 |
| 101 // This method is called after processing a message. |
| 102 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { |
| 103 // TODO(oshima): X11/Xlib.h imports various definitions that |
| 104 // caused compilation error. |
| 105 NOTIMPLEMENTED(); |
| 106 } |
| 107 #elif defined(TOOLKIT_USES_GTK) |
101 // This method is called before processing a message. | 108 // This method is called before processing a message. |
102 virtual void WillProcessEvent(GdkEvent* event) {} | 109 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {} |
103 | 110 |
104 // This method is called after processing a message. | 111 // This method is called after processing a message. |
105 virtual void DidProcessEvent(GdkEvent* event) { | 112 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE { |
106 // Quit once the GDK_CONFIGURE event has been processed - seeing | 113 // Quit once the GDK_CONFIGURE event has been processed - seeing |
107 // this means the window sizing request that was made actually | 114 // this means the window sizing request that was made actually |
108 // happened. | 115 // happened. |
109 if (event->type == GDK_CONFIGURE) | 116 if (event->type == GDK_CONFIGURE) |
110 MessageLoop::current()->Quit(); | 117 MessageLoop::current()->Quit(); |
111 } | 118 } |
| 119 #endif |
112 }; | 120 }; |
113 #endif | |
114 }; | 121 }; |
115 | 122 |
116 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 123 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
117 #define MAYBE_SizeWindow SizeWindow | 124 #define MAYBE_SizeWindow SizeWindow |
118 #else | 125 #else |
119 // http://code.google.com/p/chromium/issues/detail?id=52602 | 126 // http://code.google.com/p/chromium/issues/detail?id=52602 |
120 // Windows has some issues resizing windows- an off by one problem, | 127 // Windows has some issues resizing windows- an off by one problem, |
121 // and a minimum size that seems too big. This file isn't included in | 128 // and a minimum size that seems too big. This file isn't included in |
122 // Mac builds yet. On Chrome OS, this test doesn't apply since ChromeOS | 129 // Mac builds yet. On Chrome OS, this test doesn't apply since ChromeOS |
123 // doesn't allow resizing of windows. | 130 // doesn't allow resizing of windows. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 WindowChangedObserver::GetInstance()); | 233 WindowChangedObserver::GetInstance()); |
227 // We use busy loop because the state is updated in notifications. | 234 // We use busy loop because the state is updated in notifications. |
228 while (html_view->state_ != HtmlDialogView::PAINTED) | 235 while (html_view->state_ != HtmlDialogView::PAINTED) |
229 MessageLoop::current()->RunAllPending(); | 236 MessageLoop::current()->RunAllPending(); |
230 | 237 |
231 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); | 238 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); |
232 | 239 |
233 MessageLoopForUI::current()->RemoveObserver( | 240 MessageLoopForUI::current()->RemoveObserver( |
234 WindowChangedObserver::GetInstance()); | 241 WindowChangedObserver::GetInstance()); |
235 } | 242 } |
OLD | NEW |