OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 class TabScrubberTest : public InProcessBrowserTest, | 35 class TabScrubberTest : public InProcessBrowserTest, |
36 public TabStripModelObserver { | 36 public TabStripModelObserver { |
37 public: | 37 public: |
38 TabScrubberTest() | 38 TabScrubberTest() |
39 : target_index_(-1) { | 39 : target_index_(-1) { |
40 } | 40 } |
41 | 41 |
42 virtual void SetUpCommandLine(CommandLine* command_line) override { | 42 void SetUpCommandLine(CommandLine* command_line) override { |
43 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
44 command_line->AppendSwitch(chromeos::switches::kNaturalScrollDefault); | 44 command_line->AppendSwitch(chromeos::switches::kNaturalScrollDefault); |
45 #endif | 45 #endif |
46 command_line->AppendSwitch(switches::kOpenAsh); | 46 command_line->AppendSwitch(switches::kOpenAsh); |
47 } | 47 } |
48 | 48 |
49 virtual void SetUpOnMainThread() override { | 49 void SetUpOnMainThread() override { |
50 TabScrubber::GetInstance()->set_activation_delay(0); | 50 TabScrubber::GetInstance()->set_activation_delay(0); |
51 | 51 |
52 // Disable external monitor scaling of coordinates. | 52 // Disable external monitor scaling of coordinates. |
53 ash::Shell* shell = ash::Shell::GetInstance(); | 53 ash::Shell* shell = ash::Shell::GetInstance(); |
54 shell->event_transformation_handler()->set_transformation_mode( | 54 shell->event_transformation_handler()->set_transformation_mode( |
55 ash::EventTransformationHandler::TRANSFORM_NONE); | 55 ash::EventTransformationHandler::TRANSFORM_NONE); |
56 } | 56 } |
57 | 57 |
58 virtual void TearDownOnMainThread() override { | 58 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 float GetStartX(Browser* browser, | 67 float GetStartX(Browser* browser, |
68 int index, | 68 int index, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 TabStrip* tab_strip = GetTabStrip(browser); | 171 TabStrip* tab_strip = GetTabStrip(browser); |
172 for (int i = 0; i < num_tabs; ++i) | 172 for (int i = 0; i < num_tabs; ++i) |
173 AddBlankTabAndShow(browser); | 173 AddBlankTabAndShow(browser); |
174 ASSERT_EQ(num_tabs + 1, browser->tab_strip_model()->count()); | 174 ASSERT_EQ(num_tabs + 1, browser->tab_strip_model()->count()); |
175 ASSERT_EQ(num_tabs, browser->tab_strip_model()->active_index()); | 175 ASSERT_EQ(num_tabs, browser->tab_strip_model()->active_index()); |
176 tab_strip->StopAnimating(true); | 176 tab_strip->StopAnimating(true); |
177 ASSERT_FALSE(tab_strip->IsAnimating()); | 177 ASSERT_FALSE(tab_strip->IsAnimating()); |
178 } | 178 } |
179 | 179 |
180 // TabStripModelObserver overrides. | 180 // TabStripModelObserver overrides. |
181 virtual void TabInsertedAt(content::WebContents* contents, | 181 void TabInsertedAt(content::WebContents* contents, |
182 int index, | 182 int index, |
183 bool foreground) override {} | 183 bool foreground) override {} |
184 virtual void TabClosingAt(TabStripModel* tab_strip_model, | 184 void TabClosingAt(TabStripModel* tab_strip_model, |
185 content::WebContents* contents, | 185 content::WebContents* contents, |
186 int index) override {} | 186 int index) override {} |
187 virtual void TabDetachedAt(content::WebContents* contents, | 187 void TabDetachedAt(content::WebContents* contents, int index) override {} |
188 int index) override {} | 188 void TabDeactivated(content::WebContents* contents) override {} |
189 virtual void TabDeactivated(content::WebContents* contents) override {} | 189 void ActiveTabChanged(content::WebContents* old_contents, |
190 virtual void ActiveTabChanged(content::WebContents* old_contents, | 190 content::WebContents* new_contents, |
191 content::WebContents* new_contents, | 191 int index, |
192 int index, | 192 int reason) override { |
193 int reason) override { | |
194 activation_order_.push_back(index); | 193 activation_order_.push_back(index); |
195 if (index == target_index_) | 194 if (index == target_index_) |
196 quit_closure_.Run(); | 195 quit_closure_.Run(); |
197 } | 196 } |
198 | 197 |
199 virtual void TabSelectionChanged( | 198 void TabSelectionChanged(TabStripModel* tab_strip_model, |
200 TabStripModel* tab_strip_model, | 199 const ui::ListSelectionModel& old_model) override {} |
201 const ui::ListSelectionModel& old_model) override {} | 200 void TabMoved(content::WebContents* contents, |
202 virtual void TabMoved(content::WebContents* contents, | 201 int from_index, |
203 int from_index, | 202 int to_index) override {} |
204 int to_index) override {} | 203 void TabChangedAt(content::WebContents* contents, |
205 virtual void TabChangedAt(content::WebContents* contents, | 204 int index, |
206 int index, | 205 TabChangeType change_type) override {} |
207 TabChangeType change_type) override {} | 206 void TabReplacedAt(TabStripModel* tab_strip_model, |
208 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 207 content::WebContents* old_contents, |
209 content::WebContents* old_contents, | 208 content::WebContents* new_contents, |
210 content::WebContents* new_contents, | 209 int index) override {} |
| 210 void TabPinnedStateChanged(content::WebContents* contents, |
211 int index) override {} | 211 int index) override {} |
212 virtual void TabPinnedStateChanged(content::WebContents* contents, | 212 void TabMiniStateChanged(content::WebContents* contents, int index) override { |
213 int index) override {} | |
214 virtual void TabMiniStateChanged(content::WebContents* contents, | |
215 int index) override { | |
216 } | 213 } |
217 virtual void TabBlockedStateChanged(content::WebContents* contents, | 214 void TabBlockedStateChanged(content::WebContents* contents, |
218 int index) override {} | 215 int index) override {} |
219 virtual void TabStripEmpty() override {} | 216 void TabStripEmpty() override {} |
220 virtual void TabStripModelDeleted() override {} | 217 void TabStripModelDeleted() override {} |
221 | 218 |
222 // History of tab activation. Scrub() resets it. | 219 // History of tab activation. Scrub() resets it. |
223 std::vector<int> activation_order_; | 220 std::vector<int> activation_order_; |
224 | 221 |
225 private: | 222 private: |
226 void RunUntilTabActive(Browser* browser, int target) { | 223 void RunUntilTabActive(Browser* browser, int target) { |
227 base::RunLoop run_loop; | 224 base::RunLoop run_loop; |
228 quit_closure_ = content::GetQuitTaskForRunLoop(&run_loop); | 225 quit_closure_ = content::GetQuitTaskForRunLoop(&run_loop); |
229 browser->tab_strip_model()->AddObserver(this); | 226 browser->tab_strip_model()->AddObserver(this); |
230 target_index_ = target; | 227 target_index_ = target; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 IN_PROC_BROWSER_TEST_F(TabScrubberTest, CloseBrowser) { | 412 IN_PROC_BROWSER_TEST_F(TabScrubberTest, CloseBrowser) { |
416 AddTabs(browser(), 1); | 413 AddTabs(browser(), 1); |
417 | 414 |
418 SendScrubEvent(browser(), 0); | 415 SendScrubEvent(browser(), 0); |
419 EXPECT_TRUE(TabScrubber::GetInstance()->IsActivationPending()); | 416 EXPECT_TRUE(TabScrubber::GetInstance()->IsActivationPending()); |
420 browser()->window()->Close(); | 417 browser()->window()->Close(); |
421 EXPECT_FALSE(TabScrubber::GetInstance()->IsActivationPending()); | 418 EXPECT_FALSE(TabScrubber::GetInstance()->IsActivationPending()); |
422 } | 419 } |
423 | 420 |
424 #endif // defined(OS_CHROMEOS) | 421 #endif // defined(OS_CHROMEOS) |
OLD | NEW |