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

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: sync 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) 70 #if defined(OS_WIN)
msw 2011/09/27 01:16:46 It looks like you could share the class decl, ctor
oshima 2011/09/27 02:12:12 Done for class decl etc. I didn't share impl as it
71 class WindowChangedObserver : public MessageLoopForUI::Observer { 71 class WindowChangedObserver : public MessageLoopForUI::Observer {
72 public: 72 public:
73 WindowChangedObserver() {} 73 WindowChangedObserver() {}
74 74
75 static WindowChangedObserver* GetInstance() { 75 static WindowChangedObserver* GetInstance() {
76 return Singleton<WindowChangedObserver>::get(); 76 return Singleton<WindowChangedObserver>::get();
77 } 77 }
78 78
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 MSG& msg) OVERRIDE {
msw 2011/09/27 01:16:46 name/type (here and below), this should fit on a s
oshima 2011/09/27 02:12:12 Done.
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 MSG& msg) 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)
89 MessageLoop::current()->Quit(); 92 MessageLoop::current()->Quit();
90 } 93 }
91 }; 94 };
92 #elif !defined(OS_MACOSX) 95 #elif defined(TOUCH_UI) || defined(USE_AURA)
93 class WindowChangedObserver : public MessageLoopForUI::Observer { 96 class WindowChangedObserver : public MessageLoopForUI::Observer {
94 public: 97 public:
95 WindowChangedObserver() {} 98 WindowChangedObserver() {}
99
100 static WindowChangedObserver* GetInstance() {
101 return Singleton<WindowChangedObserver>::get();
102 }
103
104 // This method is called before processing a message.
105 virtual base::EventStatus WillProcessEvent(const base::NativeEvent& event) {
106 return base::EVENT_CONTINUE;
107 }
108
109 // This method is called after processing a message.
110 virtual void DidProcessEvent(const base::NativeEvent& event) {
111 // TODO(oshima): X11/Xlib.h imports various definitions that
112 // caused compilation error.
113 NOTIMPLEMENTED();
114 }
115 };
116 #elif defined(TOOLKIT_USES_GTK)
117 class WindowChangedObserver : public MessageLoopForUI::Observer {
118 public:
119 WindowChangedObserver() {}
96 120
97 static WindowChangedObserver* GetInstance() { 121 static WindowChangedObserver* GetInstance() {
98 return Singleton<WindowChangedObserver>::get(); 122 return Singleton<WindowChangedObserver>::get();
99 } 123 }
100 124
101 // This method is called before processing a message. 125 // This method is called before processing a message.
102 virtual void WillProcessEvent(GdkEvent* event) {} 126 virtual void WillProcessEvent(GdkEvent* event) {}
103 127
104 // This method is called after processing a message. 128 // This method is called after processing a message.
105 virtual void DidProcessEvent(GdkEvent* event) { 129 virtual void DidProcessEvent(GdkEvent* event) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 162
139 MessageLoopForUI::current()->AddObserver( 163 MessageLoopForUI::current()->AddObserver(
140 WindowChangedObserver::GetInstance()); 164 WindowChangedObserver::GetInstance());
141 165
142 gfx::Rect bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); 166 gfx::Rect bounds = html_view->GetWidget()->GetClientAreaScreenBounds();
143 167
144 gfx::Rect set_bounds = bounds; 168 gfx::Rect set_bounds = bounds;
145 gfx::Rect actual_bounds, rwhv_bounds; 169 gfx::Rect actual_bounds, rwhv_bounds;
146 170
147 // Bigger than the default in both dimensions. 171 // Bigger than the default in both dimensions.
172
148 set_bounds.set_width(400); 173 set_bounds.set_width(400);
149 set_bounds.set_height(300); 174 set_bounds.set_height(300);
150 175
151 html_view->MoveContents(tab_contents, set_bounds); 176 html_view->MoveContents(tab_contents, set_bounds);
152 ui_test_utils::RunMessageLoop(); 177 ui_test_utils::RunMessageLoop();
153 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); 178 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds();
154 EXPECT_EQ(set_bounds, actual_bounds); 179 EXPECT_EQ(set_bounds, actual_bounds);
155 180
156 rwhv_bounds = 181 rwhv_bounds =
157 html_view->tab_contents()->GetRenderWidgetHostView()->GetViewBounds(); 182 html_view->tab_contents()->GetRenderWidgetHostView()->GetViewBounds();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 WindowChangedObserver::GetInstance()); 251 WindowChangedObserver::GetInstance());
227 // We use busy loop because the state is updated in notifications. 252 // We use busy loop because the state is updated in notifications.
228 while (html_view->state_ != HtmlDialogView::PAINTED) 253 while (html_view->state_ != HtmlDialogView::PAINTED)
229 MessageLoop::current()->RunAllPending(); 254 MessageLoop::current()->RunAllPending();
230 255
231 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); 256 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_);
232 257
233 MessageLoopForUI::current()->RemoveObserver( 258 MessageLoopForUI::current()->RemoveObserver(
234 WindowChangedObserver::GetInstance()); 259 WindowChangedObserver::GetInstance());
235 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698