OLD | NEW |
---|---|
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 Loading... | |
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_thumb_thickness(0); | |
danakj
2014/09/03 17:20:51
Hm, I guess this is building the assumption that t
MuVen
2014/09/03 18:08:47
Valid point !!! Changes Done.
| |
233 scrollbar_layer->fake_scrollbar()->set_thumb_length(0); | |
234 scrollbar_layer->fake_scrollbar()->set_has_thumb(false); | |
235 | |
236 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | |
237 EXPECT_EQ(gfx::Rect(10, 0, 0, 0).ToString(), | |
238 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | |
239 } | |
240 | |
195 TEST(ScrollbarLayerTest, ThumbRect) { | 241 TEST(ScrollbarLayerTest, ThumbRect) { |
196 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 242 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
197 scoped_refptr<Layer> root_clip_layer = Layer::Create(); | 243 scoped_refptr<Layer> root_clip_layer = Layer::Create(); |
198 scoped_refptr<Layer> root_layer = Layer::Create(); | 244 scoped_refptr<Layer> root_layer = Layer::Create(); |
199 scoped_refptr<Layer> content_layer = Layer::Create(); | 245 scoped_refptr<Layer> content_layer = Layer::Create(); |
200 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 246 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
201 FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); | 247 FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); |
202 | 248 |
203 root_layer->SetScrollClipLayerId(root_clip_layer->id()); | 249 root_layer->SetScrollClipLayerId(root_clip_layer->id()); |
204 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). | 250 // 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 Loading... | |
909 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 955 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
910 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 956 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
911 | 957 |
912 // Horizontal Scrollbars. | 958 // Horizontal Scrollbars. |
913 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 959 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
914 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 960 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
915 } | 961 } |
916 | 962 |
917 } // namespace | 963 } // namespace |
918 } // namespace cc | 964 } // namespace cc |
OLD | NEW |