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

Side by Side Diff: ash/common/system/tray/tray_details_view_unittest.cc

Issue 2557333003: [ash-md] Stacks child layers properly for sticky header rows (Closed)
Patch Set: [ash-md] Stacks child layers properly for sticky header rows (no shill changes) Created 4 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
« no previous file with comments | « ash/common/system/tray/tray_details_view.cc ('k') | ash/common/system/tray/tray_popup_utils.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/common/system/tray/tray_details_view.h" 5 #include "ash/common/system/tray/tray_details_view.h"
6 6
7 #include "ash/common/ash_view_ids.h"
7 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/system/tray/hover_highlight_view.h" 9 #include "ash/common/system/tray/hover_highlight_view.h"
9 #include "ash/common/system/tray/special_popup_row.h" 10 #include "ash/common/system/tray/special_popup_row.h"
10 #include "ash/common/system/tray/system_tray.h" 11 #include "ash/common/system/tray/system_tray.h"
11 #include "ash/common/system/tray/system_tray_item.h" 12 #include "ash/common/system/tray/system_tray_item.h"
12 #include "ash/common/system/tray/tray_constants.h" 13 #include "ash/common/system/tray/tray_constants.h"
13 #include "ash/common/system/tray/tray_popup_header_button.h" 14 #include "ash/common/system/tray/tray_popup_header_button.h"
14 #include "ash/common/system/tray/view_click_listener.h" 15 #include "ash/common/system/tray/view_click_listener.h"
15 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
16 #include "base/run_loop.h" 17 #include "base/run_loop.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 54
54 tray_popup_header_button_ = 55 tray_popup_header_button_ =
55 new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED, 56 new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED,
56 IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED, 57 IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED,
57 IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER, 58 IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER,
58 IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER, 59 IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER,
59 IDS_ASH_STATUS_TRAY_BLUETOOTH); 60 IDS_ASH_STATUS_TRAY_BLUETOOTH);
60 title_row()->AddViewToRowNonMd(tray_popup_header_button_, true); 61 title_row()->AddViewToRowNonMd(tray_popup_header_button_, true);
61 } 62 }
62 63
64 void CreateScrollerViews() { CreateScrollableList(); }
65
63 private: 66 private:
64 TrayPopupHeaderButton* tray_popup_header_button_; 67 TrayPopupHeaderButton* tray_popup_header_button_;
65 68
66 DISALLOW_COPY_AND_ASSIGN(TestDetailsView); 69 DISALLOW_COPY_AND_ASSIGN(TestDetailsView);
67 }; 70 };
68 71
69 // Trivial item implementation that tracks its views for testing. 72 // Trivial item implementation that tracks its views for testing.
70 class TestItem : public SystemTrayItem { 73 class TestItem : public SystemTrayItem {
71 public: 74 public:
72 TestItem() 75 TestItem()
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 308
306 ui::test::EventGenerator& generator = GetEventGenerator(); 309 ui::test::EventGenerator& generator = GetEventGenerator();
307 gfx::Rect bounds = button->GetBoundsInScreen(); 310 gfx::Rect bounds = button->GetBoundsInScreen();
308 gfx::Point initial_point(bounds.x() - 1, bounds.y()); 311 gfx::Point initial_point(bounds.x() - 1, bounds.y());
309 generator.set_current_location(initial_point); 312 generator.set_current_location(initial_point);
310 generator.MoveMouseBy(1, 0); 313 generator.MoveMouseBy(1, 0);
311 RunAllPendingInMessageLoop(); 314 RunAllPendingInMessageLoop();
312 EXPECT_TRUE(button->background()); 315 EXPECT_TRUE(button->background());
313 } 316 }
314 317
318 TEST_F(TrayDetailsViewTest, ScrollContentsTest) {
319 SystemTray* tray = GetPrimarySystemTray();
320 TestItem* test_item = new TestItem;
321 tray->AddTrayItem(test_item);
322 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
323 RunAllPendingInMessageLoop();
324 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING);
325 RunAllPendingInMessageLoop();
326 test_item->detailed_view()->CreateScrollerViews();
327
328 test_item->detailed_view()->scroll_content()->SetPaintToLayer(true);
329 views::View* view1 = new views::View();
330 test_item->detailed_view()->scroll_content()->AddChildView(view1);
331 views::View* view2 = new views::View();
332 view2->SetPaintToLayer(true);
333 test_item->detailed_view()->scroll_content()->AddChildView(view2);
334 views::View* view3 = new views::View();
335 view3->SetPaintToLayer(true);
336 test_item->detailed_view()->scroll_content()->AddChildView(view3);
337
338 // Child layers should have same order as the child views.
339 const std::vector<ui::Layer*>& layers =
340 test_item->detailed_view()->scroll_content()->layer()->children();
341 EXPECT_EQ(2u, layers.size());
342 EXPECT_EQ(view2->layer(), layers[0]);
343 EXPECT_EQ(view3->layer(), layers[1]);
344
345 // Mark |view2| as sticky and add one more child (which will reorder layers).
346 view2->set_id(VIEW_ID_STICKY_HEADER);
347 views::View* view4 = new views::View();
348 view4->SetPaintToLayer(true);
349 test_item->detailed_view()->scroll_content()->AddChildView(view4);
350
351 // Sticky header layer should be above the last child's layer.
352 EXPECT_EQ(3u, layers.size());
353 EXPECT_EQ(view3->layer(), layers[0]);
354 EXPECT_EQ(view4->layer(), layers[1]);
355 EXPECT_EQ(view2->layer(), layers[2]);
356 }
357
315 } // namespace test 358 } // namespace test
316 } // namespace ash 359 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_details_view.cc ('k') | ash/common/system/tray/tray_popup_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698