Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: chrome/browser/ui/views/html_dialog_view_browsertest.cc

Issue 8021009: Consolidate message observer API for win and aura (and touch). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed msw's comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 (msg.message == WM_PAINT || msg.message == WM_TIMER)
msw 2011/09/27 03:51:42 event.message
oshima 2011/09/27 16:39:39 Done.
89 MessageLoop::current()->Quit(); 92 MessageLoop::current()->Quit();
90 } 93 }
91 };
92 #elif !defined(OS_MACOSX)
93 class WindowChangedObserver : public MessageLoopForUI::Observer {
94 public:
95 WindowChangedObserver() {}
96 94
97 static WindowChangedObserver* GetInstance() { 95 #elif defined(TOUCH_UI) || defined(USE_AURA)
98 return Singleton<WindowChangedObserver>::get(); 96 // This method is called before processing a message.
97 virtual base::EventStatus WillProcessEvent(const base::NativeEvent& event) {
98 return base::EVENT_CONTINUE;
99 } 99 }
100 100
101 // This method is called after processing a message.
102 virtual void DidProcessEvent(const base::NativeEvent& event) {
103 // TODO(oshima): X11/Xlib.h imports various definitions that
104 // caused compilation error.
105 NOTIMPLEMENTED();
106 }
107 };
108 #elif defined(TOOLKIT_USES_GTK)
101 // This method is called before processing a message. 109 // This method is called before processing a message.
102 virtual void WillProcessEvent(GdkEvent* event) {} 110 virtual void WillProcessEvent(GdkEvent* event) {}
103 111
104 // This method is called after processing a message. 112 // This method is called after processing a message.
105 virtual void DidProcessEvent(GdkEvent* event) { 113 virtual void DidProcessEvent(GdkEvent* event) {
106 // Quit once the GDK_CONFIGURE event has been processed - seeing 114 // Quit once the GDK_CONFIGURE event has been processed - seeing
107 // this means the window sizing request that was made actually 115 // this means the window sizing request that was made actually
108 // happened. 116 // happened.
109 if (event->type == GDK_CONFIGURE) 117 if (event->type == GDK_CONFIGURE)
110 MessageLoop::current()->Quit(); 118 MessageLoop::current()->Quit();
111 } 119 }
120 #endif
112 }; 121 };
113 #endif
114 }; 122 };
115 123
116 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 124 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
117 #define MAYBE_SizeWindow SizeWindow 125 #define MAYBE_SizeWindow SizeWindow
118 #else 126 #else
119 // http://code.google.com/p/chromium/issues/detail?id=52602 127 // http://code.google.com/p/chromium/issues/detail?id=52602
120 // Windows has some issues resizing windows- an off by one problem, 128 // 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 129 // 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 130 // Mac builds yet. On Chrome OS, this test doesn't apply since ChromeOS
123 // doesn't allow resizing of windows. 131 // doesn't allow resizing of windows.
(...skipping 14 matching lines...) Expand all
138 146
139 MessageLoopForUI::current()->AddObserver( 147 MessageLoopForUI::current()->AddObserver(
140 WindowChangedObserver::GetInstance()); 148 WindowChangedObserver::GetInstance());
141 149
142 gfx::Rect bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); 150 gfx::Rect bounds = html_view->GetWidget()->GetClientAreaScreenBounds();
143 151
144 gfx::Rect set_bounds = bounds; 152 gfx::Rect set_bounds = bounds;
145 gfx::Rect actual_bounds, rwhv_bounds; 153 gfx::Rect actual_bounds, rwhv_bounds;
146 154
147 // Bigger than the default in both dimensions. 155 // Bigger than the default in both dimensions.
156
sadrul 2011/09/27 04:13:23 -blank line
oshima 2011/09/27 16:39:39 Done.
148 set_bounds.set_width(400); 157 set_bounds.set_width(400);
149 set_bounds.set_height(300); 158 set_bounds.set_height(300);
150 159
151 html_view->MoveContents(tab_contents, set_bounds); 160 html_view->MoveContents(tab_contents, set_bounds);
152 ui_test_utils::RunMessageLoop(); 161 ui_test_utils::RunMessageLoop();
153 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); 162 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds();
154 EXPECT_EQ(set_bounds, actual_bounds); 163 EXPECT_EQ(set_bounds, actual_bounds);
155 164
156 rwhv_bounds = 165 rwhv_bounds =
157 html_view->tab_contents()->GetRenderWidgetHostView()->GetViewBounds(); 166 html_view->tab_contents()->GetRenderWidgetHostView()->GetViewBounds();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 WindowChangedObserver::GetInstance()); 235 WindowChangedObserver::GetInstance());
227 // We use busy loop because the state is updated in notifications. 236 // We use busy loop because the state is updated in notifications.
228 while (html_view->state_ != HtmlDialogView::PAINTED) 237 while (html_view->state_ != HtmlDialogView::PAINTED)
229 MessageLoop::current()->RunAllPending(); 238 MessageLoop::current()->RunAllPending();
230 239
231 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); 240 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_);
232 241
233 MessageLoopForUI::current()->RemoveObserver( 242 MessageLoopForUI::current()->RemoveObserver(
234 WindowChangedObserver::GetInstance()); 243 WindowChangedObserver::GetInstance());
235 } 244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698