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

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

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 int GetTabCenter(Browser* browser, int index) { 75 int GetTabCenter(Browser* browser, int index) {
76 return GetTabStrip(browser)->tab_at(index)->bounds().CenterPoint().x(); 76 return GetTabStrip(browser)->tab_at(index)->bounds().CenterPoint().x();
77 } 77 }
78 78
79 // Sends one scroll event synchronously without initial or final 79 // Sends one scroll event synchronously without initial or final
80 // fling events. 80 // fling events.
81 void SendScrubEvent(Browser* browser, int index) { 81 void SendScrubEvent(Browser* browser, int index) {
82 aura::Window* window = browser->window()->GetNativeWindow(); 82 aura::Window* window = browser->window()->GetNativeWindow();
83 aura::RootWindow* root = window->GetRootWindow(); 83 aura::Window* root = window->GetRootWindow();
84 aura::test::EventGenerator event_generator(root, window); 84 aura::test::EventGenerator event_generator(root, window);
85 int active_index = browser->tab_strip_model()->active_index(); 85 int active_index = browser->tab_strip_model()->active_index();
86 TabScrubber::Direction direction = index < active_index ? 86 TabScrubber::Direction direction = index < active_index ?
87 TabScrubber::LEFT : TabScrubber::RIGHT; 87 TabScrubber::LEFT : TabScrubber::RIGHT;
88 int offset = GetTabCenter(browser, index) - 88 int offset = GetTabCenter(browser, index) -
89 GetStartX(browser, active_index, direction); 89 GetStartX(browser, active_index, direction);
90 ui::ScrollEvent scroll_event(ui::ET_SCROLL, 90 ui::ScrollEvent scroll_event(ui::ET_SCROLL,
91 gfx::Point(0, 0), 91 gfx::Point(0, 0),
92 ui::EventTimeForNow(), 92 ui::EventTimeForNow(),
93 0, 93 0,
94 offset, 0, 94 offset, 0,
95 offset, 0, 95 offset, 0,
96 3); 96 3);
97 event_generator.Dispatch(&scroll_event); 97 event_generator.Dispatch(&scroll_event);
98 } 98 }
99 99
100 enum ScrubType { 100 enum ScrubType {
101 EACH_TAB, 101 EACH_TAB,
102 SKIP_TABS, 102 SKIP_TABS,
103 REPEAT_TABS, 103 REPEAT_TABS,
104 }; 104 };
105 105
106 // Sends asynchronous events and waits for tab at |index| to become 106 // Sends asynchronous events and waits for tab at |index| to become
107 // active. 107 // active.
108 void Scrub(Browser* browser, int index, ScrubType scrub_type) { 108 void Scrub(Browser* browser, int index, ScrubType scrub_type) {
109 aura::Window* window = browser->window()->GetNativeWindow(); 109 aura::Window* window = browser->window()->GetNativeWindow();
110 aura::RootWindow* root = window->GetRootWindow(); 110 aura::Window* root = window->GetRootWindow();
111 aura::test::EventGenerator event_generator(root, window); 111 aura::test::EventGenerator event_generator(root, window);
112 event_generator.set_async(true); 112 event_generator.set_async(true);
113 activation_order_.clear(); 113 activation_order_.clear();
114 int active_index = browser->tab_strip_model()->active_index(); 114 int active_index = browser->tab_strip_model()->active_index();
115 ASSERT_NE(index, active_index); 115 ASSERT_NE(index, active_index);
116 ASSERT_TRUE(scrub_type != SKIP_TABS || ((index - active_index) % 2) == 0); 116 ASSERT_TRUE(scrub_type != SKIP_TABS || ((index - active_index) % 2) == 0);
117 TabScrubber::Direction direction; 117 TabScrubber::Direction direction;
118 int increment; 118 int increment;
119 if (index < active_index) { 119 if (index < active_index) {
120 direction = TabScrubber::LEFT; 120 direction = TabScrubber::LEFT;
(...skipping 22 matching lines...) Expand all
143 3); 143 3);
144 RunUntilTabActive(browser, index); 144 RunUntilTabActive(browser, index);
145 } 145 }
146 146
147 // Sends events and waits for tab at |index| to become active 147 // Sends events and waits for tab at |index| to become active
148 // if it's different from the currently active tab. 148 // if it's different from the currently active tab.
149 // 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
150 // synchronously (as we don't have anything to wait for). 150 // synchronously (as we don't have anything to wait for).
151 void SendScrubSequence(Browser* browser, int x_offset, int index) { 151 void SendScrubSequence(Browser* browser, int x_offset, int index) {
152 aura::Window* window = browser->window()->GetNativeWindow(); 152 aura::Window* window = browser->window()->GetNativeWindow();
153 aura::RootWindow* root = window->GetRootWindow(); 153 aura::Window* root = window->GetRootWindow();
154 aura::test::EventGenerator event_generator(root, window); 154 aura::test::EventGenerator event_generator(root, window);
155 bool wait_for_active = false; 155 bool wait_for_active = false;
156 if (index != browser->tab_strip_model()->active_index()) { 156 if (index != browser->tab_strip_model()->active_index()) {
157 wait_for_active = true; 157 wait_for_active = true;
158 event_generator.set_async(true); 158 event_generator.set_async(true);
159 } 159 }
160 event_generator.ScrollSequence(gfx::Point(0, 0), 160 event_generator.ScrollSequence(gfx::Point(0, 0),
161 ui::EventTimeForNow(), 161 ui::EventTimeForNow(),
162 x_offset, 162 x_offset,
163 0, 163 0,
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 IN_PROC_BROWSER_TEST_F(TabScrubberTest, CloseBrowser) { 415 IN_PROC_BROWSER_TEST_F(TabScrubberTest, CloseBrowser) {
416 AddTabs(browser(), 1); 416 AddTabs(browser(), 1);
417 417
418 SendScrubEvent(browser(), 0); 418 SendScrubEvent(browser(), 0);
419 EXPECT_TRUE(TabScrubber::GetInstance()->IsActivationPending()); 419 EXPECT_TRUE(TabScrubber::GetInstance()->IsActivationPending());
420 browser()->window()->Close(); 420 browser()->window()->Close();
421 EXPECT_FALSE(TabScrubber::GetInstance()->IsActivationPending()); 421 EXPECT_FALSE(TabScrubber::GetInstance()->IsActivationPending());
422 } 422 }
423 423
424 #endif // OS_CHROMEOS 424 #endif // OS_CHROMEOS
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/apps/native_app_window_views.cc ('k') | chrome/browser/ui/views/certificate_viewer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698