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

Side by Side Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 524373003: Scrollbar ThumbLength is not updated when window size is changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed review comments Created 6 years, 3 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
« no previous file with comments | « cc/layers/painted_scrollbar_layer.cc ('k') | cc/test/fake_scrollbar.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/containers/hash_tables.h" 5 #include "base/containers/hash_tables.h"
6 #include "cc/animation/scrollbar_animation_controller.h" 6 #include "cc/animation/scrollbar_animation_controller.h"
7 #include "cc/layers/append_quads_data.h" 7 #include "cc/layers/append_quads_data.h"
8 #include "cc/layers/painted_scrollbar_layer.h" 8 #include "cc/layers/painted_scrollbar_layer.h"
9 #include "cc/layers/painted_scrollbar_layer_impl.h" 9 #include "cc/layers/painted_scrollbar_layer_impl.h"
10 #include "cc/layers/scrollbar_layer_interface.h" 10 #include "cc/layers/scrollbar_layer_interface.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 #define UPDATE_AND_EXTRACT_LAYER_POINTERS() \ 185 #define UPDATE_AND_EXTRACT_LAYER_POINTERS() \
186 do { \ 186 do { \
187 scrollbar_layer->UpdateThumbAndTrackGeometry(); \ 187 scrollbar_layer->UpdateThumbAndTrackGeometry(); \
188 root_clip_layer_impl = host->CommitAndCreateLayerImplTree(); \ 188 root_clip_layer_impl = host->CommitAndCreateLayerImplTree(); \
189 root_layer_impl = root_clip_layer_impl->children()[0]; \ 189 root_layer_impl = root_clip_layer_impl->children()[0]; \
190 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( \ 190 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( \
191 root_layer_impl->children()[1]); \ 191 root_layer_impl->children()[1]); \
192 scrollbar_layer_impl->ScrollbarParametersDidChange(); \ 192 scrollbar_layer_impl->ScrollbarParametersDidChange(); \
193 } while (false) 193 } while (false)
194 194
195 TEST(ScrollbarLayerTest, UpdatePropertiesOfScrollBarWhenThumbRemoved) {
196 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
197 scoped_refptr<Layer> root_clip_layer = Layer::Create();
198 scoped_refptr<Layer> root_layer = Layer::Create();
199 scoped_refptr<Layer> content_layer = Layer::Create();
200 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
201 FakePaintedScrollbarLayer::Create(false, true, root_layer->id());
202
203 root_layer->SetScrollClipLayerId(root_clip_layer->id());
204 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0).
205 root_clip_layer->SetBounds(gfx::Size(20, 50));
206 root_layer->SetBounds(gfx::Size(100, 50));
207 content_layer->SetBounds(gfx::Size(100, 50));
208
209 host->SetRootLayer(root_clip_layer);
210 root_clip_layer->AddChild(root_layer);
211 root_layer->AddChild(content_layer);
212 root_layer->AddChild(scrollbar_layer);
213
214 root_layer->SetScrollOffset(gfx::Vector2d(0, 0));
215 scrollbar_layer->SetBounds(gfx::Size(70, 10));
216 scrollbar_layer->SetScrollLayer(root_layer->id());
217 scrollbar_layer->SetClipLayer(root_clip_layer->id());
218 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10));
219 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10));
220 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10);
221 scrollbar_layer->fake_scrollbar()->set_thumb_length(4);
222
223 scrollbar_layer->UpdateThumbAndTrackGeometry();
224 LayerImpl* root_clip_layer_impl = NULL;
225 LayerImpl* root_layer_impl = NULL;
226 PaintedScrollbarLayerImpl* scrollbar_layer_impl = NULL;
227
228 UPDATE_AND_EXTRACT_LAYER_POINTERS();
229 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(),
230 scrollbar_layer_impl->ComputeThumbQuadRect().ToString());
231
232 scrollbar_layer->fake_scrollbar()->set_has_thumb(false);
233
234 UPDATE_AND_EXTRACT_LAYER_POINTERS();
235 EXPECT_EQ(gfx::Rect(10, 0, 0, 0).ToString(),
236 scrollbar_layer_impl->ComputeThumbQuadRect().ToString());
237 }
238
195 TEST(ScrollbarLayerTest, ThumbRect) { 239 TEST(ScrollbarLayerTest, ThumbRect) {
196 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); 240 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
197 scoped_refptr<Layer> root_clip_layer = Layer::Create(); 241 scoped_refptr<Layer> root_clip_layer = Layer::Create();
198 scoped_refptr<Layer> root_layer = Layer::Create(); 242 scoped_refptr<Layer> root_layer = Layer::Create();
199 scoped_refptr<Layer> content_layer = Layer::Create(); 243 scoped_refptr<Layer> content_layer = Layer::Create();
200 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = 244 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
201 FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); 245 FakePaintedScrollbarLayer::Create(false, true, root_layer->id());
202 246
203 root_layer->SetScrollClipLayerId(root_clip_layer->id()); 247 root_layer->SetScrollClipLayerId(root_clip_layer->id());
204 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). 248 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0).
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 953 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
910 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 954 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
911 955
912 // Horizontal Scrollbars. 956 // Horizontal Scrollbars.
913 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 957 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
914 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 958 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
915 } 959 }
916 960
917 } // namespace 961 } // namespace
918 } // namespace cc 962 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/painted_scrollbar_layer.cc ('k') | cc/test/fake_scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698