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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 1980163002: Use black for resize gutter in tab fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
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 "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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 OverscrollMode current_mode_; 145 OverscrollMode current_mode_;
146 OverscrollMode completed_mode_; 146 OverscrollMode completed_mode_;
147 float delta_x_; 147 float delta_x_;
148 float delta_y_; 148 float delta_y_;
149 149
150 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); 150 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate);
151 }; 151 };
152 152
153 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { 153 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate {
154 public: 154 public:
155 MockRenderWidgetHostDelegate() : rwh_(nullptr) {} 155 MockRenderWidgetHostDelegate() : rwh_(nullptr), is_fullscreen_(false) {}
156 ~MockRenderWidgetHostDelegate() override {} 156 ~MockRenderWidgetHostDelegate() override {}
157 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } 157 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); }
158 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } 158 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; }
159 void set_is_fullscreen(bool is_fullscreen) { is_fullscreen_ = is_fullscreen; }
159 160
160 protected: 161 protected:
161 // RenderWidgetHostDelegate: 162 // RenderWidgetHostDelegate:
162 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 163 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
163 bool* is_keyboard_shortcut) override { 164 bool* is_keyboard_shortcut) override {
164 last_event_.reset(new NativeWebKeyboardEvent(event)); 165 last_event_.reset(new NativeWebKeyboardEvent(event));
165 return true; 166 return true;
166 } 167 }
167 void Cut() override {} 168 void Cut() override {}
168 void Copy() override {} 169 void Copy() override {}
169 void Paste() override {} 170 void Paste() override {}
170 void SelectAll() override {} 171 void SelectAll() override {}
171 void SendScreenRects() override { 172 void SendScreenRects() override {
172 if (rwh_) 173 if (rwh_)
173 rwh_->SendScreenRects(); 174 rwh_->SendScreenRects();
174 } 175 }
176 bool IsFullscreenForCurrentTab(
177 RenderWidgetHostImpl* render_widget_host) const override {
178 return is_fullscreen_;
179 }
175 180
176 private: 181 private:
177 scoped_ptr<NativeWebKeyboardEvent> last_event_; 182 scoped_ptr<NativeWebKeyboardEvent> last_event_;
178 RenderWidgetHostImpl* rwh_; 183 RenderWidgetHostImpl* rwh_;
184 bool is_fullscreen_;
185
179 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); 186 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate);
180 }; 187 };
181 188
182 // Simple observer that keeps track of changes to a window for tests. 189 // Simple observer that keeps track of changes to a window for tests.
183 class TestWindowObserver : public aura::WindowObserver { 190 class TestWindowObserver : public aura::WindowObserver {
184 public: 191 public:
185 explicit TestWindowObserver(aura::Window* window_to_observe) 192 explicit TestWindowObserver(aura::Window* window_to_observe)
186 : window_(window_to_observe) { 193 : window_(window_to_observe) {
187 window_->AddObserver(this); 194 window_->AddObserver(this);
188 } 195 }
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 view_->OnSwapCompositorFrame(0, std::move(frame)); 1717 view_->OnSwapCompositorFrame(0, std::move(frame));
1711 1718
1712 ui::Layer* parent_layer = view_->GetNativeView()->layer(); 1719 ui::Layer* parent_layer = view_->GetNativeView()->layer();
1713 1720
1714 ASSERT_EQ(2u, parent_layer->children().size()); 1721 ASSERT_EQ(2u, parent_layer->children().size());
1715 EXPECT_EQ(gfx::Rect(40, 0, 60, 100), parent_layer->children()[0]->bounds()); 1722 EXPECT_EQ(gfx::Rect(40, 0, 60, 100), parent_layer->children()[0]->bounds());
1716 EXPECT_EQ(SK_ColorRED, parent_layer->children()[0]->background_color()); 1723 EXPECT_EQ(SK_ColorRED, parent_layer->children()[0]->background_color());
1717 EXPECT_EQ(gfx::Rect(0, 45, 40, 55), parent_layer->children()[1]->bounds()); 1724 EXPECT_EQ(gfx::Rect(0, 45, 40, 55), parent_layer->children()[1]->bounds());
1718 EXPECT_EQ(SK_ColorRED, parent_layer->children()[1]->background_color()); 1725 EXPECT_EQ(SK_ColorRED, parent_layer->children()[1]->background_color());
1719 1726
1727 delegates_.back()->set_is_fullscreen(true);
1720 view_->SetSize(medium_size); 1728 view_->SetSize(medium_size);
1721 1729
1722 // Right gutter is unnecessary. 1730 // Right gutter is unnecessary.
1723 ASSERT_EQ(1u, parent_layer->children().size()); 1731 ASSERT_EQ(1u, parent_layer->children().size());
1724 EXPECT_EQ(gfx::Rect(0, 45, 40, 50), parent_layer->children()[0]->bounds()); 1732 EXPECT_EQ(gfx::Rect(0, 45, 40, 50), parent_layer->children()[0]->bounds());
1725 1733
1734 // RWH is fullscreen, so gutters should be black.
1735 EXPECT_EQ(SK_ColorBLACK, parent_layer->children()[0]->background_color());
1736
1726 frame = MakeDelegatedFrame(1.f, medium_size, gfx::Rect(medium_size)); 1737 frame = MakeDelegatedFrame(1.f, medium_size, gfx::Rect(medium_size));
1727 view_->OnSwapCompositorFrame(0, std::move(frame)); 1738 view_->OnSwapCompositorFrame(0, std::move(frame));
1728 EXPECT_EQ(0u, parent_layer->children().size()); 1739 EXPECT_EQ(0u, parent_layer->children().size());
1729 1740
1730 view_->SetSize(large_size); 1741 view_->SetSize(large_size);
1731 ASSERT_EQ(2u, parent_layer->children().size()); 1742 ASSERT_EQ(2u, parent_layer->children().size());
1732 1743
1733 // This should evict the frame and remove the gutter layers. 1744 // This should evict the frame and remove the gutter layers.
1734 view_->Hide(); 1745 view_->Hide();
1735 view_->SetSize(small_size); 1746 view_->SetSize(small_size);
(...skipping 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after
4472 view()->OnGestureEvent(&gesture_event); 4483 view()->OnGestureEvent(&gesture_event);
4473 4484
4474 EXPECT_TRUE(delegate->context_menu_request_received()); 4485 EXPECT_TRUE(delegate->context_menu_request_received());
4475 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); 4486 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH);
4476 #endif 4487 #endif
4477 4488
4478 RenderViewHostFactory::set_is_real_render_view_host(false); 4489 RenderViewHostFactory::set_is_real_render_view_host(false);
4479 } 4490 }
4480 4491
4481 } // namespace content 4492 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698