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 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 } | 81 } |
82 }; | 82 }; |
83 | 83 |
84 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | 84 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
85 public: | 85 public: |
86 MockRenderWidgetHostDelegate() {} | 86 MockRenderWidgetHostDelegate() {} |
87 virtual ~MockRenderWidgetHostDelegate() {} | 87 virtual ~MockRenderWidgetHostDelegate() {} |
88 }; | 88 }; |
89 | 89 |
90 // Simple observer that keeps track of changes to a window for tests. | 90 // Simple observer that keeps track of changes to a window for tests. |
91 class TestWindowObserver : public aura::WindowObserver { | 91 class TestWindowObserver : public aura::WindowObserver { |
sadrul
2014/02/03 19:29:37
Hm. We should eventually get rid of this and use a
| |
92 public: | 92 public: |
93 explicit TestWindowObserver(aura::Window* window_to_observe) | 93 explicit TestWindowObserver(aura::Window* window_to_observe) |
94 : window_(window_to_observe) { | 94 : window_(window_to_observe) { |
95 window_->AddObserver(this); | 95 window_->AddObserver(this); |
96 } | 96 } |
97 virtual ~TestWindowObserver() { | 97 virtual ~TestWindowObserver() { |
98 if (window_) | 98 if (window_) |
99 window_->RemoveObserver(this); | 99 window_->RemoveObserver(this); |
100 } | 100 } |
101 | 101 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 view_->InitAsPopup(parent_view_, gfx::Rect(10, 10, 100, 100)); | 410 view_->InitAsPopup(parent_view_, gfx::Rect(10, 10, 100, 100)); |
411 aura::Window* window = view_->GetNativeView(); | 411 aura::Window* window = view_->GetNativeView(); |
412 ASSERT_TRUE(window != NULL); | 412 ASSERT_TRUE(window != NULL); |
413 | 413 |
414 gfx::Point click_point; | 414 gfx::Point click_point; |
415 EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(click_point)); | 415 EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(click_point)); |
416 aura::Window* parent_window = parent_view_->GetNativeView(); | 416 aura::Window* parent_window = parent_view_->GetNativeView(); |
417 EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(click_point)); | 417 EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(click_point)); |
418 | 418 |
419 TestWindowObserver observer(window); | 419 TestWindowObserver observer(window); |
420 aura::test::EventGenerator generator(window->GetRootWindow(), gfx::Point()); | 420 aura::test::EventGenerator generator(window->GetRootWindow(), click_point); |
421 generator.ClickLeftButton(); | 421 generator.ClickLeftButton(); |
422 ASSERT_TRUE(parent_view_->HasFocus()); | 422 ASSERT_TRUE(parent_view_->HasFocus()); |
423 ASSERT_TRUE(observer.destroyed()); | 423 ASSERT_TRUE(observer.destroyed()); |
424 | 424 |
425 widget_host_ = NULL; | 425 widget_host_ = NULL; |
426 view_ = NULL; | 426 view_ = NULL; |
427 } | 427 } |
428 | 428 |
429 // Checks that a popup view is destroyed when a user taps outside of the popup | |
430 // view and focus does not change. This is the case when the user taps the | |
431 // desktop background on Chrome OS. | |
432 TEST_F(RenderWidgetHostViewAuraTest, DestroyPopupTapOutsidePopup) { | |
433 parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400)); | |
434 parent_view_->Focus(); | |
435 EXPECT_TRUE(parent_view_->HasFocus()); | |
436 | |
437 view_->InitAsPopup(parent_view_, gfx::Rect(10, 10, 100, 100)); | |
438 aura::Window* window = view_->GetNativeView(); | |
439 ASSERT_TRUE(window != NULL); | |
440 | |
441 gfx::Point tap_point; | |
442 EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(tap_point)); | |
443 aura::Window* parent_window = parent_view_->GetNativeView(); | |
444 EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(tap_point)); | |
445 | |
446 TestWindowObserver observer(window); | |
447 aura::test::EventGenerator generator(window->GetRootWindow(), tap_point); | |
448 generator.GestureTapAt(tap_point); | |
449 ASSERT_TRUE(parent_view_->HasFocus()); | |
450 ASSERT_TRUE(observer.destroyed()); | |
451 | |
452 widget_host_ = NULL; | |
453 view_ = NULL; | |
454 } | |
455 | |
429 // Checks that IME-composition-event state is maintained correctly. | 456 // Checks that IME-composition-event state is maintained correctly. |
430 TEST_F(RenderWidgetHostViewAuraTest, SetCompositionText) { | 457 TEST_F(RenderWidgetHostViewAuraTest, SetCompositionText) { |
431 view_->InitAsChild(NULL); | 458 view_->InitAsChild(NULL); |
432 view_->Show(); | 459 view_->Show(); |
433 | 460 |
434 ui::CompositionText composition_text; | 461 ui::CompositionText composition_text; |
435 composition_text.text = base::ASCIIToUTF16("|a|b"); | 462 composition_text.text = base::ASCIIToUTF16("|a|b"); |
436 | 463 |
437 // Focused segment | 464 // Focused segment |
438 composition_text.underlines.push_back( | 465 composition_text.underlines.push_back( |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1386 | 1413 |
1387 // Because the copy request callback may be holding state within it, that | 1414 // Because the copy request callback may be holding state within it, that |
1388 // state must handle the RWHVA and ImageTransportFactory going away before the | 1415 // state must handle the RWHVA and ImageTransportFactory going away before the |
1389 // callback is called. This test passes if it does not crash as a result of | 1416 // callback is called. This test passes if it does not crash as a result of |
1390 // these things being destroyed. | 1417 // these things being destroyed. |
1391 EXPECT_EQ(2, callback_count_); | 1418 EXPECT_EQ(2, callback_count_); |
1392 EXPECT_FALSE(result_); | 1419 EXPECT_FALSE(result_); |
1393 } | 1420 } |
1394 | 1421 |
1395 } // namespace content | 1422 } // namespace content |
OLD | NEW |