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

Side by Side Diff: chrome/browser/ui/views/ash/tab_scrubber_browsertest.cc

Issue 660173002: Type conversion fixes, ui/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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 | « no previous file | ui/base/accelerators/accelerator.cc » ('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 (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 "chrome/browser/ui/views/ash/tab_scrubber.h" 5 #include "chrome/browser/ui/views/ash/tab_scrubber.h"
6 6
7 #include "ash/display/event_transformation_handler.h" 7 #include "ash/display/event_transformation_handler.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 virtual void TearDownOnMainThread() override { 58 virtual void TearDownOnMainThread() override {
59 browser()->tab_strip_model()->RemoveObserver(this); 59 browser()->tab_strip_model()->RemoveObserver(this);
60 } 60 }
61 61
62 TabStrip* GetTabStrip(Browser* browser) { 62 TabStrip* GetTabStrip(Browser* browser) {
63 aura::Window* window = browser->window()->GetNativeWindow(); 63 aura::Window* window = browser->window()->GetNativeWindow();
64 return BrowserView::GetBrowserViewForNativeWindow(window)->tabstrip(); 64 return BrowserView::GetBrowserViewForNativeWindow(window)->tabstrip();
65 } 65 }
66 66
67 int GetStartX(Browser* browser, 67 float GetStartX(Browser* browser,
68 int index, 68 int index,
69 TabScrubber::Direction direction) { 69 TabScrubber::Direction direction) {
70 return TabScrubber::GetStartPoint( 70 return static_cast<float>(TabScrubber::GetStartPoint(
71 GetTabStrip(browser), index, direction).x(); 71 GetTabStrip(browser), index, direction).x());
72 } 72 }
73 73
74 int GetTabCenter(Browser* browser, int index) { 74 float GetTabCenter(Browser* browser, int index) {
75 return GetTabStrip(browser)->tab_at(index)->bounds().CenterPoint().x(); 75 return static_cast<float>(
76 GetTabStrip(browser)->tab_at(index)->bounds().CenterPoint().x());
76 } 77 }
77 78
78 // Sends one scroll event synchronously without initial or final 79 // Sends one scroll event synchronously without initial or final
79 // fling events. 80 // fling events.
80 void SendScrubEvent(Browser* browser, int index) { 81 void SendScrubEvent(Browser* browser, int index) {
81 aura::Window* window = browser->window()->GetNativeWindow(); 82 aura::Window* window = browser->window()->GetNativeWindow();
82 aura::Window* root = window->GetRootWindow(); 83 aura::Window* root = window->GetRootWindow();
83 ui::test::EventGenerator event_generator(root, window); 84 ui::test::EventGenerator event_generator(root, window);
84 int active_index = browser->tab_strip_model()->active_index(); 85 int active_index = browser->tab_strip_model()->active_index();
85 TabScrubber::Direction direction = index < active_index ? 86 TabScrubber::Direction direction = index < active_index ?
86 TabScrubber::LEFT : TabScrubber::RIGHT; 87 TabScrubber::LEFT : TabScrubber::RIGHT;
87 int offset = GetTabCenter(browser, index) - 88 float offset = GetTabCenter(browser, index) -
88 GetStartX(browser, active_index, direction); 89 GetStartX(browser, active_index, direction);
89 ui::ScrollEvent scroll_event(ui::ET_SCROLL, 90 ui::ScrollEvent scroll_event(ui::ET_SCROLL,
90 gfx::Point(0, 0), 91 gfx::PointF(0, 0),
91 ui::EventTimeForNow(), 92 ui::EventTimeForNow(),
92 0, 93 0,
93 offset, 0, 94 offset, 0,
94 offset, 0, 95 offset, 0,
95 3); 96 3);
96 event_generator.Dispatch(&scroll_event); 97 event_generator.Dispatch(&scroll_event);
97 } 98 }
98 99
99 enum ScrubType { 100 enum ScrubType {
100 EACH_TAB, 101 EACH_TAB,
(...skipping 16 matching lines...) Expand all
117 int increment; 118 int increment;
118 if (index < active_index) { 119 if (index < active_index) {
119 direction = TabScrubber::LEFT; 120 direction = TabScrubber::LEFT;
120 increment = -1; 121 increment = -1;
121 } else { 122 } else {
122 direction = TabScrubber::RIGHT; 123 direction = TabScrubber::RIGHT;
123 increment = 1; 124 increment = 1;
124 } 125 }
125 if (scrub_type == SKIP_TABS) 126 if (scrub_type == SKIP_TABS)
126 increment *= 2; 127 increment *= 2;
127 int last = GetStartX(browser, active_index, direction); 128 float last = GetStartX(browser, active_index, direction);
128 std::vector<gfx::Point> offsets; 129 std::vector<gfx::PointF> offsets;
129 for (int i = active_index + increment; i != (index + increment); 130 for (int i = active_index + increment; i != (index + increment);
130 i += increment) { 131 i += increment) {
131 int tab_center = GetTabCenter(browser, i); 132 float tab_center = GetTabCenter(browser, i);
132 offsets.push_back(gfx::Point(tab_center - last, 0)); 133 offsets.push_back(gfx::PointF(tab_center - last, 0));
133 last = GetStartX(browser, i, direction); 134 last = GetStartX(browser, i, direction);
134 if (scrub_type == REPEAT_TABS) { 135 if (scrub_type == REPEAT_TABS) {
135 offsets.push_back(gfx::Point(increment, 0)); 136 offsets.push_back(gfx::PointF(static_cast<float>(increment), 0));
136 last += increment; 137 last += increment;
137 } 138 }
138 } 139 }
139 event_generator.ScrollSequence(gfx::Point(0, 0), 140 event_generator.ScrollSequence(gfx::Point(0, 0),
140 base::TimeDelta::FromMilliseconds(100), 141 base::TimeDelta::FromMilliseconds(100),
141 offsets, 142 offsets,
142 3); 143 3);
143 RunUntilTabActive(browser, index); 144 RunUntilTabActive(browser, index);
144 } 145 }
145 146
146 // Sends events and waits for tab at |index| to become active 147 // Sends events and waits for tab at |index| to become active
147 // if it's different from the currently active tab. 148 // if it's different from the currently active tab.
148 // If the active tab is expected to stay the same, send events 149 // If the active tab is expected to stay the same, send events
149 // synchronously (as we don't have anything to wait for). 150 // synchronously (as we don't have anything to wait for).
150 void SendScrubSequence(Browser* browser, int x_offset, int index) { 151 void SendScrubSequence(Browser* browser, float x_offset, int index) {
151 aura::Window* window = browser->window()->GetNativeWindow(); 152 aura::Window* window = browser->window()->GetNativeWindow();
152 aura::Window* root = window->GetRootWindow(); 153 aura::Window* root = window->GetRootWindow();
153 ui::test::EventGenerator event_generator(root, window); 154 ui::test::EventGenerator event_generator(root, window);
154 bool wait_for_active = false; 155 bool wait_for_active = false;
155 if (index != browser->tab_strip_model()->active_index()) { 156 if (index != browser->tab_strip_model()->active_index()) {
156 wait_for_active = true; 157 wait_for_active = true;
157 event_generator.set_async(true); 158 event_generator.set_async(true);
158 } 159 }
159 event_generator.ScrollSequence(gfx::Point(0, 0), 160 event_generator.ScrollSequence(gfx::Point(0, 0),
160 ui::EventTimeForNow(), 161 ui::EventTimeForNow(),
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 IN_PROC_BROWSER_TEST_F(TabScrubberTest, CloseBrowser) { 415 IN_PROC_BROWSER_TEST_F(TabScrubberTest, CloseBrowser) {
415 AddTabs(browser(), 1); 416 AddTabs(browser(), 1);
416 417
417 SendScrubEvent(browser(), 0); 418 SendScrubEvent(browser(), 0);
418 EXPECT_TRUE(TabScrubber::GetInstance()->IsActivationPending()); 419 EXPECT_TRUE(TabScrubber::GetInstance()->IsActivationPending());
419 browser()->window()->Close(); 420 browser()->window()->Close();
420 EXPECT_FALSE(TabScrubber::GetInstance()->IsActivationPending()); 421 EXPECT_FALSE(TabScrubber::GetInstance()->IsActivationPending());
421 } 422 }
422 423
423 #endif // defined(OS_CHROMEOS) 424 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | ui/base/accelerators/accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698