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

Side by Side Diff: ui/views/bubble/bubble_delegate_unittest.cc

Issue 89503003: Close bubble widget when its anchor widget bounds has changed and move_with_anchor is false. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « ui/views/bubble/bubble_delegate.cc ('k') | ui/views/bubble/tray_bubble_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "ui/base/hit_test.h" 6 #include "ui/base/hit_test.h"
7 #include "ui/views/bubble/bubble_delegate.h" 7 #include "ui/views/bubble/bubble_delegate.h"
8 #include "ui/views/bubble/bubble_frame_view.h" 8 #include "ui/views/bubble/bubble_frame_view.h"
9 #include "ui/views/test/test_widget_observer.h" 9 #include "ui/views/test/test_widget_observer.h"
10 #include "ui/views/test/views_test_base.h" 10 #include "ui/views/test/views_test_base.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 { 1000, HTNOWHERE }, 237 { 1000, HTNOWHERE },
238 }; 238 };
239 239
240 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 240 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
241 gfx::Point point(cases[i].point, cases[i].point); 241 gfx::Point point(cases[i].point, cases[i].point);
242 EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point)) 242 EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point))
243 << " with border: " << border << ", at point " << cases[i].point; 243 << " with border: " << border << ", at point " << cases[i].point;
244 } 244 }
245 } 245 }
246 246
247 TEST_F(BubbleDelegateTest, CloseWhenAnchorWidgetBoundsChanged) {
248 scoped_ptr<Widget> anchor_widget(CreateTestWidget());
249 BubbleDelegateView* bubble_delegate = new BubbleDelegateView(
250 anchor_widget->GetContentsView(), BubbleBorder::NONE);
251 Widget* bubble_widget = BubbleDelegateView::CreateBubble(bubble_delegate);
252 test::TestWidgetObserver bubble_observer(bubble_widget);
253 EXPECT_FALSE(bubble_observer.widget_closed());
254
255 bubble_widget->Show();
256 EXPECT_TRUE(bubble_widget->IsVisible());
257 anchor_widget->SetBounds(gfx::Rect(10, 10, 100, 100));
258 EXPECT_FALSE(bubble_widget->IsVisible());
259 }
260
247 // This class provides functionality to verify that the BubbleView shows up 261 // This class provides functionality to verify that the BubbleView shows up
248 // when we call BubbleDelegateView::StartFade(true) and is destroyed when we 262 // when we call BubbleDelegateView::StartFade(true) and is destroyed when we
249 // call BubbleDelegateView::StartFade(false). 263 // call BubbleDelegateView::StartFade(false).
250 class BubbleWidgetClosingTest : public BubbleDelegateTest, 264 class BubbleWidgetClosingTest : public BubbleDelegateTest,
251 public views::WidgetObserver { 265 public views::WidgetObserver {
252 public: 266 public:
253 BubbleWidgetClosingTest() : bubble_destroyed_(false) { 267 BubbleWidgetClosingTest() : bubble_destroyed_(false) {
254 #if defined(USE_AURA) 268 #if defined(USE_AURA)
255 aura::Env::CreateInstance(); 269 aura::Env::CreateInstance();
256 loop_.set_dispatcher(aura::Env::GetInstance()->GetDispatcher()); 270 loop_.set_dispatcher(aura::Env::GetInstance()->GetDispatcher());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 bubble_widget->GetFocusManager()->GetFocusedView()); 311 bubble_widget->GetFocusManager()->GetFocusedView());
298 312
299 Observe(bubble_widget); 313 Observe(bubble_widget);
300 314
301 bubble_delegate->StartFade(false); 315 bubble_delegate->StartFade(false);
302 RunNestedLoop(); 316 RunNestedLoop();
303 EXPECT_TRUE(bubble_destroyed()); 317 EXPECT_TRUE(bubble_destroyed());
304 } 318 }
305 319
306 } // namespace views 320 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_delegate.cc ('k') | ui/views/bubble/tray_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698