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

Side by Side Diff: chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller_unittest.mm

Issue 2072003002: Desktop Capture Picker Window New UI For Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unittest Created 4 years, 6 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
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 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h" 5 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/media/desktop_media_list_observer.h" 10 #include "chrome/browser/media/desktop_media_list_observer.h"
11 #include "chrome/browser/media/fake_desktop_media_list.h" 11 #include "chrome/browser/media/fake_desktop_media_list.h"
12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
13 #include "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h"
tapted 2016/06/29 12:46:20 nit: import
qiangchen 2016/06/29 18:15:04 Done.
13 #include "content/public/test/test_browser_thread_bundle.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
14 #include "testing/gtest_mac.h" 15 #include "testing/gtest_mac.h"
15 16
tapted 2016/06/29 12:46:20 a `using content::DesktopMediaID` here would proba
qiangchen 2016/06/29 18:15:03 Done.
17 #define MAKE_WINDOW_ID(id) \
18 content::DesktopMediaID(content::DesktopMediaID::TYPE_WINDOW, id)
tapted 2016/06/29 12:46:20 This is not a good reason to use macros see http:/
qiangchen 2016/06/29 18:15:04 Done.
19 #define MAKE_SCREEN_ID(id) \
20 content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, id)
21 #define MAKE_TAB_ID(id) \
22 content::DesktopMediaID(content::DesktopMediaID::TYPE_WEB_CONTENTS, id)
23
16 @interface DesktopMediaPickerController (ExposedForTesting) 24 @interface DesktopMediaPickerController (ExposedForTesting)
17 - (IKImageBrowserView*)sourceBrowser; 25 - (IKImageBrowserView*)screenBrowser;
26 - (IKImageBrowserView*)windowBrowser;
27 - (NSTableView*)tabBrowser;
28 - (NSSegmentedControl*)sourceTypeControl;
18 - (NSButton*)shareButton; 29 - (NSButton*)shareButton;
19 - (NSButton*)audioShareCheckbox; 30 - (NSButton*)audioShareCheckbox;
20 - (NSArray*)items; 31 - (NSArray*)screenItems;
32 - (NSArray*)windowItems;
33 - (NSArray*)tabItems;
21 @end 34 @end
22 35
23 @implementation DesktopMediaPickerController (ExposedForTesting) 36 @implementation DesktopMediaPickerController (ExposedForTesting)
24 - (IKImageBrowserView*)sourceBrowser { 37 - (IKImageBrowserView*)screenBrowser {
25 return sourceBrowser_; 38 return screenBrowser_;
39 }
40
41 - (IKImageBrowserView*)windowBrowser {
42 return windowBrowser_;
43 }
44
45 - (NSTableView*)tabBrowser {
46 return tabBrowser_;
47 }
48
49 - (NSSegmentedControl*)sourceTypeControl {
50 return sourceTypeControl_;
26 } 51 }
27 52
28 - (NSButton*)shareButton { 53 - (NSButton*)shareButton {
29 return shareButton_; 54 return shareButton_;
30 } 55 }
31 56
32 - (NSButton*)cancelButton { 57 - (NSButton*)cancelButton {
33 return cancelButton_; 58 return cancelButton_;
34 } 59 }
35 60
36 - (NSButton*)audioShareCheckbox { 61 - (NSButton*)audioShareCheckbox {
37 return audioShareCheckbox_; 62 return audioShareCheckbox_;
38 } 63 }
39 64
40 - (NSArray*)items { 65 - (NSArray*)screenItems {
41 return items_; 66 return screenItems_;
42 } 67 }
68
69 - (NSArray*)windowItems {
70 return windowItems_;
71 }
72
73 - (NSArray*)tabItems {
74 return tabItems_;
75 }
76
43 @end 77 @end
44 78
45 class DesktopMediaPickerControllerTest : public CocoaTest { 79 class DesktopMediaPickerControllerTest : public CocoaTest {
46 public: 80 public:
47 DesktopMediaPickerControllerTest() {} 81 DesktopMediaPickerControllerTest() {}
48 82
49 void SetUp() override { 83 void SetUp() override {
50 CocoaTest::SetUp(); 84 CocoaTest::SetUp();
51 85
52 screen_list_ = new FakeDesktopMediaList(); 86 screen_list_ = new FakeDesktopMediaList();
(...skipping 20 matching lines...) Expand all
73 CocoaTest::TearDown(); 107 CocoaTest::TearDown();
74 } 108 }
75 109
76 bool WaitForCallback() { 110 bool WaitForCallback() {
77 if (!callback_called_) { 111 if (!callback_called_) {
78 base::RunLoop().RunUntilIdle(); 112 base::RunLoop().RunUntilIdle();
79 } 113 }
80 return callback_called_; 114 return callback_called_;
81 } 115 }
82 116
117 void ChangeType(content::DesktopMediaID::Type sourceType) {
118 NSSegmentedControl* control = [controller_ sourceTypeControl];
119 [control selectSegmentWithTag:sourceType];
120 // [control selectSegmentWithTag] does not trigger handler, so we need to
121 // trigger it manually.
122 [controller_ performSelector:[control action] withObject:control];
tapted 2016/06/29 12:46:19 nit: controller_ -> [control target]
qiangchen 2016/06/29 18:15:04 Done.
123 }
124
83 protected: 125 protected:
84 void OnResult(content::DesktopMediaID source) { 126 void OnResult(content::DesktopMediaID source) {
85 EXPECT_FALSE(callback_called_); 127 EXPECT_FALSE(callback_called_);
86 callback_called_ = true; 128 callback_called_ = true;
87 source_reported_ = source; 129 source_reported_ = source;
88 } 130 }
89 131
90 content::TestBrowserThreadBundle thread_bundle_; 132 content::TestBrowserThreadBundle thread_bundle_;
91 bool callback_called_ = false; 133 bool callback_called_ = false;
92 content::DesktopMediaID source_reported_; 134 content::DesktopMediaID source_reported_;
93 FakeDesktopMediaList* screen_list_ = nullptr; 135 FakeDesktopMediaList* screen_list_ = nullptr;
94 FakeDesktopMediaList* window_list_ = nullptr; 136 FakeDesktopMediaList* window_list_ = nullptr;
95 FakeDesktopMediaList* tab_list_ = nullptr; 137 FakeDesktopMediaList* tab_list_ = nullptr;
96 base::scoped_nsobject<DesktopMediaPickerController> controller_; 138 base::scoped_nsobject<DesktopMediaPickerController> controller_;
97 }; 139 };
98 140
99 TEST_F(DesktopMediaPickerControllerTest, ShowAndDismiss) { 141 TEST_F(DesktopMediaPickerControllerTest, ShowAndDismiss) {
100 [controller_ showWindow:nil]; 142 [controller_ showWindow:nil];
143 ChangeType(content::DesktopMediaID::TYPE_SCREEN);
101 144
102 window_list_->AddSource(0); 145 screen_list_->AddSourceByFullMediaID(MAKE_SCREEN_ID(0));
103 window_list_->AddSource(1); 146 screen_list_->AddSourceByFullMediaID(MAKE_SCREEN_ID(1));
104 window_list_->SetSourceThumbnail(1); 147 screen_list_->SetSourceThumbnail(1);
105 148
106 NSArray* items = [controller_ items]; 149 NSArray* items = [controller_ screenItems];
107 EXPECT_EQ(2U, [items count]); 150 EXPECT_EQ(2U, [items count]);
108 EXPECT_NSEQ(@"0", [[items objectAtIndex:0] imageTitle]); 151 EXPECT_NSEQ(@"0", [[items objectAtIndex:0] imageTitle]);
109 EXPECT_EQ(nil, [[items objectAtIndex:0] imageRepresentation]); 152 EXPECT_EQ(nil, [[items objectAtIndex:0] imageRepresentation]);
110 EXPECT_NSEQ(@"1", [[items objectAtIndex:1] imageTitle]); 153 EXPECT_NSEQ(@"1", [[items objectAtIndex:1] imageTitle]);
111 EXPECT_TRUE([[items objectAtIndex:1] imageRepresentation] != nil); 154 EXPECT_TRUE([[items objectAtIndex:1] imageRepresentation] != nil);
112 } 155 }
113 156
114 TEST_F(DesktopMediaPickerControllerTest, ClickShare) { 157 TEST_F(DesktopMediaPickerControllerTest, ClickShare) {
115 [controller_ showWindow:nil]; 158 [controller_ showWindow:nil];
159 ChangeType(content::DesktopMediaID::TYPE_WEB_CONTENTS);
160 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(0));
161 tab_list_->SetSourceThumbnail(0);
162 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(1));
163 tab_list_->SetSourceThumbnail(1);
116 164
117 window_list_->AddSource(0); 165 EXPECT_EQ(2U, [[controller_ tabItems] count]);
118 window_list_->SetSourceThumbnail(0);
119 window_list_->AddSource(1);
120 window_list_->SetSourceThumbnail(1);
121
122 EXPECT_EQ(2U, [[controller_ items] count]);
123 EXPECT_FALSE([[controller_ shareButton] isEnabled]); 166 EXPECT_FALSE([[controller_ shareButton] isEnabled]);
124 167
125 NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:1]; 168 NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:1];
126 [[controller_ sourceBrowser] setSelectionIndexes:indexSet 169 [[controller_ tabBrowser] selectRowIndexes:indexSet byExtendingSelection:NO];
127 byExtendingSelection:NO];
128 EXPECT_TRUE([[controller_ shareButton] isEnabled]); 170 EXPECT_TRUE([[controller_ shareButton] isEnabled]);
129 171
172 [[controller_ audioShareCheckbox] setState:NSOffState];
tapted 2016/06/29 12:46:19 comment about this?
qiangchen 2016/06/29 18:15:04 Done.
130 [[controller_ shareButton] performClick:nil]; 173 [[controller_ shareButton] performClick:nil];
131 EXPECT_TRUE(WaitForCallback()); 174 EXPECT_TRUE(WaitForCallback());
132 EXPECT_EQ(window_list_->GetSource(1).id, source_reported_); 175 EXPECT_EQ(tab_list_->GetSource(1).id, source_reported_);
133 } 176 }
tapted 2016/06/29 12:46:19 At a minimum, the ClickShare test should test each
qiangchen 2016/06/29 18:15:04 Done.
134 177
135 TEST_F(DesktopMediaPickerControllerTest, ClickCancel) { 178 TEST_F(DesktopMediaPickerControllerTest, ClickCancel) {
136 [controller_ showWindow:nil]; 179 [controller_ showWindow:nil];
180 ChangeType(content::DesktopMediaID::TYPE_WINDOW);
137 181
138 window_list_->AddSource(0); 182 window_list_->AddSourceByFullMediaID(MAKE_WINDOW_ID(0));
139 window_list_->SetSourceThumbnail(0); 183 window_list_->SetSourceThumbnail(0);
140 window_list_->AddSource(1); 184 window_list_->AddSourceByFullMediaID(MAKE_WINDOW_ID(1));
141 window_list_->SetSourceThumbnail(1); 185 window_list_->SetSourceThumbnail(1);
142 186
tapted 2016/06/29 12:46:20 Something should get selected here - it's not very
qiangchen 2016/06/29 18:15:04 Done.
143 [[controller_ cancelButton] performClick:nil]; 187 [[controller_ cancelButton] performClick:nil];
144 EXPECT_TRUE(WaitForCallback()); 188 EXPECT_TRUE(WaitForCallback());
145 EXPECT_EQ(content::DesktopMediaID(), source_reported_); 189 EXPECT_EQ(content::DesktopMediaID(), source_reported_);
146 } 190 }
147 191
148 TEST_F(DesktopMediaPickerControllerTest, CloseWindow) { 192 TEST_F(DesktopMediaPickerControllerTest, CloseWindow) {
149 [controller_ showWindow:nil]; 193 [controller_ showWindow:nil];
194 ChangeType(content::DesktopMediaID::TYPE_SCREEN);
150 195
151 window_list_->AddSource(0); 196 screen_list_->AddSourceByFullMediaID(MAKE_SCREEN_ID(0));
152 window_list_->SetSourceThumbnail(0); 197 screen_list_->SetSourceThumbnail(0);
153 window_list_->AddSource(1); 198 screen_list_->AddSourceByFullMediaID(MAKE_SCREEN_ID(1));
154 window_list_->SetSourceThumbnail(1); 199 screen_list_->SetSourceThumbnail(1);
155 200
156 [controller_ close]; 201 [controller_ close];
157 EXPECT_TRUE(WaitForCallback()); 202 EXPECT_TRUE(WaitForCallback());
158 EXPECT_EQ(content::DesktopMediaID(), source_reported_); 203 EXPECT_EQ(content::DesktopMediaID(), source_reported_);
159 } 204 }
160 205
161 TEST_F(DesktopMediaPickerControllerTest, UpdateThumbnail) { 206 TEST_F(DesktopMediaPickerControllerTest, UpdateThumbnail) {
162 [controller_ showWindow:nil]; 207 [controller_ showWindow:nil];
208 ChangeType(content::DesktopMediaID::TYPE_WEB_CONTENTS);
tapted 2016/06/29 12:46:19 Does the WebContents type have thumbnails or just
qiangchen 2016/06/29 18:15:04 Just icon, but the way we process it is the same a
163 209
164 window_list_->AddSource(0); 210 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(0));
165 window_list_->SetSourceThumbnail(0); 211 tab_list_->SetSourceThumbnail(0);
166 window_list_->AddSource(1); 212 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(1));
167 window_list_->SetSourceThumbnail(1); 213 tab_list_->SetSourceThumbnail(1);
168 214
169 NSArray* items = [controller_ items]; 215 NSArray* items = [controller_ tabItems];
170 EXPECT_EQ(2U, [items count]); 216 EXPECT_EQ(2U, [items count]);
171 NSUInteger version = [[items objectAtIndex:0] imageVersion]; 217 NSUInteger version = [[items objectAtIndex:0] imageVersion];
172 218
173 window_list_->SetSourceThumbnail(0); 219 tab_list_->SetSourceThumbnail(0);
174 EXPECT_NE(version, [[items objectAtIndex:0] imageVersion]); 220 EXPECT_NE(version, [[items objectAtIndex:0] imageVersion]);
175 } 221 }
176 222
177 TEST_F(DesktopMediaPickerControllerTest, UpdateName) { 223 TEST_F(DesktopMediaPickerControllerTest, UpdateName) {
178 [controller_ showWindow:nil]; 224 [controller_ showWindow:nil];
225 ChangeType(content::DesktopMediaID::TYPE_WINDOW);
179 226
180 window_list_->AddSource(0); 227 window_list_->AddSourceByFullMediaID(MAKE_WINDOW_ID(0));
181 window_list_->SetSourceThumbnail(0); 228 window_list_->SetSourceThumbnail(0);
182 window_list_->AddSource(1); 229 window_list_->AddSourceByFullMediaID(MAKE_WINDOW_ID(1));
183 window_list_->SetSourceThumbnail(1); 230 window_list_->SetSourceThumbnail(1);
184 231
185 NSArray* items = [controller_ items]; 232 NSArray* items = [controller_ windowItems];
186 EXPECT_EQ(2U, [items count]); 233 EXPECT_EQ(2U, [items count]);
187 NSUInteger version = [[items objectAtIndex:0] imageVersion]; 234 NSUInteger version = [[items objectAtIndex:0] imageVersion];
188 235
189 window_list_->SetSourceThumbnail(0); 236 window_list_->SetSourceThumbnail(0);
190 EXPECT_NE(version, [[items objectAtIndex:0] imageVersion]); 237 EXPECT_NE(version, [[items objectAtIndex:0] imageVersion]);
191 } 238 }
192 239
193 TEST_F(DesktopMediaPickerControllerTest, RemoveSource) { 240 TEST_F(DesktopMediaPickerControllerTest, RemoveSource) {
194 [controller_ showWindow:nil]; 241 [controller_ showWindow:nil];
242 ChangeType(content::DesktopMediaID::TYPE_SCREEN);
195 243
196 window_list_->AddSource(0); 244 screen_list_->AddSourceByFullMediaID(MAKE_SCREEN_ID(0));
197 window_list_->AddSource(1); 245 screen_list_->AddSourceByFullMediaID(MAKE_SCREEN_ID(1));
198 window_list_->AddSource(2); 246 screen_list_->AddSourceByFullMediaID(MAKE_SCREEN_ID(2));
199 window_list_->SetSourceName(1, base::ASCIIToUTF16("foo")); 247 screen_list_->SetSourceName(1, base::ASCIIToUTF16("foo"));
200 248
201 NSArray* items = [controller_ items]; 249 NSArray* items = [controller_ screenItems];
202 EXPECT_EQ(3U, [items count]); 250 EXPECT_EQ(3U, [items count]);
203 EXPECT_NSEQ(@"foo", [[items objectAtIndex:1] imageTitle]); 251 EXPECT_NSEQ(@"foo", [[items objectAtIndex:1] imageTitle]);
204 } 252 }
205 253
206 TEST_F(DesktopMediaPickerControllerTest, MoveSource) { 254 TEST_F(DesktopMediaPickerControllerTest, MoveSource) {
207 [controller_ showWindow:nil]; 255 [controller_ showWindow:nil];
256 ChangeType(content::DesktopMediaID::TYPE_WEB_CONTENTS);
208 257
209 window_list_->AddSource(0); 258 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(0));
210 window_list_->AddSource(1); 259 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(1));
211 window_list_->SetSourceName(1, base::ASCIIToUTF16("foo")); 260 tab_list_->SetSourceName(1, base::ASCIIToUTF16("foo"));
212 NSArray* items = [controller_ items]; 261 NSArray* items = [controller_ tabItems];
213 EXPECT_NSEQ(@"foo", [[items objectAtIndex:1] imageTitle]); 262 EXPECT_NSEQ(@"foo", [[items objectAtIndex:1] imageTitle]);
214 263
215 window_list_->MoveSource(1, 0); 264 tab_list_->MoveSource(1, 0);
216 EXPECT_NSEQ(@"foo", [[items objectAtIndex:0] imageTitle]); 265 EXPECT_NSEQ(@"foo", [[items objectAtIndex:0] imageTitle]);
217 266
218 window_list_->MoveSource(0, 1); 267 tab_list_->MoveSource(0, 1);
219 EXPECT_NSEQ(@"foo", [[items objectAtIndex:1] imageTitle]); 268 EXPECT_NSEQ(@"foo", [[items objectAtIndex:1] imageTitle]);
220 } 269 }
tapted 2016/06/29 12:46:19 the other media types have very different codepath
qiangchen 2016/06/29 18:15:04 Done.
221 270
222 // Make sure the audio share checkbox' state reacts correctly with 271 // Make sure the audio share checkbox' state reacts correctly with
223 // the source selection. Namely the checkbox is enabled only for tab 272 // the source selection. Namely the checkbox is enabled only for tab
224 // sharing on Mac. 273 // sharing on Mac.
225 TEST_F(DesktopMediaPickerControllerTest, AudioShareCheckboxState) { 274 TEST_F(DesktopMediaPickerControllerTest, AudioShareCheckboxState) {
226 [controller_ showWindow:nil]; 275 [controller_ showWindow:nil];
227 276
228 screen_list_->AddSourceByFullMediaID( 277 screen_list_->AddSourceByFullMediaID(MAKE_SCREEN_ID(0));
229 content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, 0)); 278 window_list_->AddSourceByFullMediaID(MAKE_WINDOW_ID(1));
230 window_list_->AddSourceByFullMediaID( 279 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(2));
231 content::DesktopMediaID(content::DesktopMediaID::TYPE_WINDOW, 1));
232 tab_list_->AddSourceByFullMediaID(
233 content::DesktopMediaID(content::DesktopMediaID::TYPE_WEB_CONTENTS, 2));
234 280
235 NSButton* checkbox = [controller_ audioShareCheckbox]; 281 NSButton* checkbox = [controller_ audioShareCheckbox];
236 EXPECT_EQ(NO, [checkbox isEnabled]); 282 EXPECT_EQ(YES, [checkbox isHidden]);
237 283
238 NSIndexSet* index_set = [NSIndexSet indexSetWithIndex:0]; 284 [checkbox setHidden:NO];
239 [checkbox setEnabled:YES]; 285 ChangeType(content::DesktopMediaID::TYPE_WINDOW);
240 [[controller_ sourceBrowser] setSelectionIndexes:index_set 286 EXPECT_EQ(YES, [checkbox isHidden]);
241 byExtendingSelection:NO];
242 EXPECT_EQ(NO, [checkbox isEnabled]);
243 287
244 index_set = [NSIndexSet indexSetWithIndex:1]; 288 [checkbox setHidden:YES];
245 [checkbox setEnabled:YES]; 289 ChangeType(content::DesktopMediaID::TYPE_WEB_CONTENTS);
246 [[controller_ sourceBrowser] setSelectionIndexes:index_set 290 EXPECT_EQ(NO, [checkbox isHidden]);
247 byExtendingSelection:NO];
248 EXPECT_EQ(NO, [checkbox isEnabled]);
249 291
250 index_set = [NSIndexSet indexSetWithIndex:2]; 292 [checkbox setHidden:NO];
251 [[controller_ sourceBrowser] setSelectionIndexes:index_set 293 ChangeType(content::DesktopMediaID::TYPE_SCREEN);
252 byExtendingSelection:NO]; 294 EXPECT_EQ(YES, [checkbox isHidden]);
253 EXPECT_EQ(YES, [checkbox isEnabled]); 295 }
254 296
255 index_set = [NSIndexSet indexSet]; 297 TEST_F(DesktopMediaPickerControllerTest, TabShareWithAudio) {
256 [[controller_ sourceBrowser] setSelectionIndexes:index_set 298 [controller_ showWindow:nil];
257 byExtendingSelection:NO]; 299 ChangeType(content::DesktopMediaID::TYPE_WEB_CONTENTS);
258 EXPECT_EQ(NO, [checkbox isEnabled]); 300
301 content::DesktopMediaID origin_id = MAKE_TAB_ID(123);
302 content::DesktopMediaID id_with_audio = origin_id;
303 id_with_audio.audio_share = true;
tapted 2016/06/29 12:46:19 shouldn't this be in an EXPECT_TRUE after WaitForC
qiangchen 2016/06/29 18:15:04 No. The ID is passed by value. So the local variab
tapted 2016/06/30 00:37:01 Ah, gotcha. It looks kinda like audio_share = true
304
305 tab_list_->AddSourceByFullMediaID(origin_id);
306
307 NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:0];
tapted 2016/06/29 12:46:20 indexSet -> index_set (this doesn't lie between @i
qiangchen 2016/06/29 18:15:04 Done.
308 [[controller_ tabBrowser] selectRowIndexes:indexSet byExtendingSelection:NO];
309 EXPECT_TRUE([[controller_ shareButton] isEnabled]);
310
311 [[controller_ shareButton] performClick:nil];
312
313 EXPECT_TRUE(WaitForCallback());
314 EXPECT_EQ(id_with_audio, source_reported_);
259 } 315 }
316
317 TEST_F(DesktopMediaPickerControllerTest, TabBrowserFocusAlgorithm) {
318 [controller_ showWindow:nil];
319 ChangeType(content::DesktopMediaID::TYPE_WEB_CONTENTS);
320 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(0));
321 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(1));
322 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(2));
323 tab_list_->AddSourceByFullMediaID(MAKE_TAB_ID(3));
324
325 NSArray* items = [controller_ tabItems];
326 NSTableView* browser = [controller_ tabBrowser];
327
328 NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:1];
tapted 2016/06/29 12:46:19 index_set
qiangchen 2016/06/29 18:15:04 Done.
329 [browser selectRowIndexes:indexSet byExtendingSelection:NO];
330
331 // Move source [0, 1, 2, 3]-->[1, 2, 3, 0]
332 tab_list_->MoveSource(0, 3);
333 NSUInteger selectedIndex = [[browser selectedRowIndexes] firstIndex];
tapted 2016/06/29 12:46:19 selected_index
qiangchen 2016/06/29 18:15:04 Done.
334 EXPECT_EQ(1, [[items objectAtIndex:selectedIndex] sourceID].id);
335
336 // Move source [1, 2, 3, 0]-->[3, 1, 2, 0]
337 tab_list_->MoveSource(2, 0);
338 selectedIndex = [[browser selectedRowIndexes] firstIndex];
339 EXPECT_EQ(1, [[items objectAtIndex:selectedIndex] sourceID].id);
340
341 // Remove a source [3, 1, 2, 0]-->[1, 2, 0]
342 tab_list_->RemoveSource(0);
343 selectedIndex = [[browser selectedRowIndexes] firstIndex];
344 EXPECT_EQ(1, [[items objectAtIndex:selectedIndex] sourceID].id);
345
346 // Change source type back and forth, browser should memorize the selection.
347 ChangeType(content::DesktopMediaID::TYPE_SCREEN);
348 ChangeType(content::DesktopMediaID::TYPE_WEB_CONTENTS);
349 selectedIndex = [[browser selectedRowIndexes] firstIndex];
350 EXPECT_EQ(1, [[items objectAtIndex:selectedIndex] sourceID].id);
351 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698