| 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 virtual 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 virtual 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 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 int GetStartX(Browser* browser, |
| 68 int index, | 68 int index, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 AddBlankTabAndShow(browser); | 172 AddBlankTabAndShow(browser); |
| 173 ASSERT_EQ(num_tabs + 1, browser->tab_strip_model()->count()); | 173 ASSERT_EQ(num_tabs + 1, browser->tab_strip_model()->count()); |
| 174 ASSERT_EQ(num_tabs, browser->tab_strip_model()->active_index()); | 174 ASSERT_EQ(num_tabs, browser->tab_strip_model()->active_index()); |
| 175 tab_strip->StopAnimating(true); | 175 tab_strip->StopAnimating(true); |
| 176 ASSERT_FALSE(tab_strip->IsAnimating()); | 176 ASSERT_FALSE(tab_strip->IsAnimating()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // TabStripModelObserver overrides. | 179 // TabStripModelObserver overrides. |
| 180 virtual void TabInsertedAt(content::WebContents* contents, | 180 virtual void TabInsertedAt(content::WebContents* contents, |
| 181 int index, | 181 int index, |
| 182 bool foreground) OVERRIDE {} | 182 bool foreground) override {} |
| 183 virtual void TabClosingAt(TabStripModel* tab_strip_model, | 183 virtual void TabClosingAt(TabStripModel* tab_strip_model, |
| 184 content::WebContents* contents, | 184 content::WebContents* contents, |
| 185 int index) OVERRIDE {} | 185 int index) override {} |
| 186 virtual void TabDetachedAt(content::WebContents* contents, | 186 virtual void TabDetachedAt(content::WebContents* contents, |
| 187 int index) OVERRIDE {} | 187 int index) override {} |
| 188 virtual void TabDeactivated(content::WebContents* contents) OVERRIDE {} | 188 virtual void TabDeactivated(content::WebContents* contents) override {} |
| 189 virtual void ActiveTabChanged(content::WebContents* old_contents, | 189 virtual void ActiveTabChanged(content::WebContents* old_contents, |
| 190 content::WebContents* new_contents, | 190 content::WebContents* new_contents, |
| 191 int index, | 191 int index, |
| 192 int reason) OVERRIDE { | 192 int reason) override { |
| 193 activation_order_.push_back(index); | 193 activation_order_.push_back(index); |
| 194 if (index == target_index_) | 194 if (index == target_index_) |
| 195 quit_closure_.Run(); | 195 quit_closure_.Run(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 virtual void TabSelectionChanged( | 198 virtual void TabSelectionChanged( |
| 199 TabStripModel* tab_strip_model, | 199 TabStripModel* tab_strip_model, |
| 200 const ui::ListSelectionModel& old_model) OVERRIDE {} | 200 const ui::ListSelectionModel& old_model) override {} |
| 201 virtual void TabMoved(content::WebContents* contents, | 201 virtual void TabMoved(content::WebContents* contents, |
| 202 int from_index, | 202 int from_index, |
| 203 int to_index) OVERRIDE {} | 203 int to_index) override {} |
| 204 virtual void TabChangedAt(content::WebContents* contents, | 204 virtual void TabChangedAt(content::WebContents* contents, |
| 205 int index, | 205 int index, |
| 206 TabChangeType change_type) OVERRIDE {} | 206 TabChangeType change_type) override {} |
| 207 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 207 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
| 208 content::WebContents* old_contents, | 208 content::WebContents* old_contents, |
| 209 content::WebContents* new_contents, | 209 content::WebContents* new_contents, |
| 210 int index) OVERRIDE {} | 210 int index) override {} |
| 211 virtual void TabPinnedStateChanged(content::WebContents* contents, | 211 virtual void TabPinnedStateChanged(content::WebContents* contents, |
| 212 int index) OVERRIDE {} | 212 int index) override {} |
| 213 virtual void TabMiniStateChanged(content::WebContents* contents, | 213 virtual void TabMiniStateChanged(content::WebContents* contents, |
| 214 int index) OVERRIDE { | 214 int index) override { |
| 215 } | 215 } |
| 216 virtual void TabBlockedStateChanged(content::WebContents* contents, | 216 virtual void TabBlockedStateChanged(content::WebContents* contents, |
| 217 int index) OVERRIDE {} | 217 int index) override {} |
| 218 virtual void TabStripEmpty() OVERRIDE {} | 218 virtual void TabStripEmpty() override {} |
| 219 virtual void TabStripModelDeleted() OVERRIDE {} | 219 virtual void TabStripModelDeleted() override {} |
| 220 | 220 |
| 221 // History of tab activation. Scrub() resets it. | 221 // History of tab activation. Scrub() resets it. |
| 222 std::vector<int> activation_order_; | 222 std::vector<int> activation_order_; |
| 223 | 223 |
| 224 private: | 224 private: |
| 225 void RunUntilTabActive(Browser* browser, int target) { | 225 void RunUntilTabActive(Browser* browser, int target) { |
| 226 base::RunLoop run_loop; | 226 base::RunLoop run_loop; |
| 227 quit_closure_ = content::GetQuitTaskForRunLoop(&run_loop); | 227 quit_closure_ = content::GetQuitTaskForRunLoop(&run_loop); |
| 228 browser->tab_strip_model()->AddObserver(this); | 228 browser->tab_strip_model()->AddObserver(this); |
| 229 target_index_ = target; | 229 target_index_ = target; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 IN_PROC_BROWSER_TEST_F(TabScrubberTest, CloseBrowser) { | 414 IN_PROC_BROWSER_TEST_F(TabScrubberTest, CloseBrowser) { |
| 415 AddTabs(browser(), 1); | 415 AddTabs(browser(), 1); |
| 416 | 416 |
| 417 SendScrubEvent(browser(), 0); | 417 SendScrubEvent(browser(), 0); |
| 418 EXPECT_TRUE(TabScrubber::GetInstance()->IsActivationPending()); | 418 EXPECT_TRUE(TabScrubber::GetInstance()->IsActivationPending()); |
| 419 browser()->window()->Close(); | 419 browser()->window()->Close(); |
| 420 EXPECT_FALSE(TabScrubber::GetInstance()->IsActivationPending()); | 420 EXPECT_FALSE(TabScrubber::GetInstance()->IsActivationPending()); |
| 421 } | 421 } |
| 422 | 422 |
| 423 #endif // defined(OS_CHROMEOS) | 423 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |