OLD | NEW |
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" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 EXPECT_EQ(2U, [items count]); | 160 EXPECT_EQ(2U, [items count]); |
161 EXPECT_NSEQ(@"0", [[items objectAtIndex:0] imageTitle]); | 161 EXPECT_NSEQ(@"0", [[items objectAtIndex:0] imageTitle]); |
162 EXPECT_EQ(nil, [[items objectAtIndex:0] imageRepresentation]); | 162 EXPECT_EQ(nil, [[items objectAtIndex:0] imageRepresentation]); |
163 EXPECT_NSEQ(@"1", [[items objectAtIndex:1] imageTitle]); | 163 EXPECT_NSEQ(@"1", [[items objectAtIndex:1] imageTitle]); |
164 EXPECT_TRUE([[items objectAtIndex:1] imageRepresentation] != nil); | 164 EXPECT_TRUE([[items objectAtIndex:1] imageRepresentation] != nil); |
165 } | 165 } |
166 | 166 |
167 TEST_F(DesktopMediaPickerControllerTest, ClickShareScreen) { | 167 TEST_F(DesktopMediaPickerControllerTest, ClickShareScreen) { |
168 [controller_ showWindow:nil]; | 168 [controller_ showWindow:nil]; |
169 ChangeType(DesktopMediaID::TYPE_SCREEN); | 169 ChangeType(DesktopMediaID::TYPE_SCREEN); |
| 170 |
| 171 EXPECT_FALSE([[controller_ shareButton] isEnabled]); |
170 AddScreen(0); | 172 AddScreen(0); |
171 screen_list_->SetSourceThumbnail(0); | 173 screen_list_->SetSourceThumbnail(0); |
| 174 // First screen will be automatically selected. |
| 175 EXPECT_TRUE([[controller_ shareButton] isEnabled]); |
| 176 |
172 AddScreen(1); | 177 AddScreen(1); |
173 screen_list_->SetSourceThumbnail(1); | 178 screen_list_->SetSourceThumbnail(1); |
174 | 179 |
175 EXPECT_EQ(2U, [[controller_ screenItems] count]); | 180 EXPECT_EQ(2U, [[controller_ screenItems] count]); |
176 EXPECT_FALSE([[controller_ shareButton] isEnabled]); | |
177 | |
178 NSIndexSet* index_set = [NSIndexSet indexSetWithIndex:1]; | |
179 [[controller_ screenBrowser] setSelectionIndexes:index_set | |
180 byExtendingSelection:NO]; | |
181 EXPECT_TRUE([[controller_ shareButton] isEnabled]); | |
182 | 181 |
183 [[controller_ shareButton] performClick:nil]; | 182 [[controller_ shareButton] performClick:nil]; |
184 EXPECT_TRUE(WaitForCallback()); | 183 EXPECT_TRUE(WaitForCallback()); |
185 EXPECT_EQ(screen_list_->GetSource(1).id, source_reported_); | 184 EXPECT_EQ(screen_list_->GetSource(0).id, source_reported_); |
186 } | 185 } |
187 | 186 |
188 TEST_F(DesktopMediaPickerControllerTest, ClickShareWindow) { | 187 TEST_F(DesktopMediaPickerControllerTest, ClickShareWindow) { |
189 [controller_ showWindow:nil]; | 188 [controller_ showWindow:nil]; |
190 ChangeType(DesktopMediaID::TYPE_WINDOW); | 189 ChangeType(DesktopMediaID::TYPE_WINDOW); |
191 AddWindow(0); | 190 AddWindow(0); |
192 window_list_->SetSourceThumbnail(0); | 191 window_list_->SetSourceThumbnail(0); |
193 AddWindow(1); | 192 AddWindow(1); |
194 window_list_->SetSourceThumbnail(1); | 193 window_list_->SetSourceThumbnail(1); |
195 | 194 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 tab_list_->RemoveSource(0); | 399 tab_list_->RemoveSource(0); |
401 selected_index = [[browser selectedRowIndexes] firstIndex]; | 400 selected_index = [[browser selectedRowIndexes] firstIndex]; |
402 EXPECT_EQ(1, [[items objectAtIndex:selected_index] sourceID].id); | 401 EXPECT_EQ(1, [[items objectAtIndex:selected_index] sourceID].id); |
403 | 402 |
404 // Change source type back and forth, browser should memorize the selection. | 403 // Change source type back and forth, browser should memorize the selection. |
405 ChangeType(DesktopMediaID::TYPE_SCREEN); | 404 ChangeType(DesktopMediaID::TYPE_SCREEN); |
406 ChangeType(DesktopMediaID::TYPE_WEB_CONTENTS); | 405 ChangeType(DesktopMediaID::TYPE_WEB_CONTENTS); |
407 selected_index = [[browser selectedRowIndexes] firstIndex]; | 406 selected_index = [[browser selectedRowIndexes] firstIndex]; |
408 EXPECT_EQ(1, [[items objectAtIndex:selected_index] sourceID].id); | 407 EXPECT_EQ(1, [[items objectAtIndex:selected_index] sourceID].id); |
409 } | 408 } |
| 409 |
| 410 TEST_F(DesktopMediaPickerControllerTest, SingleScreenNoLabel) { |
| 411 [controller_ showWindow:nil]; |
| 412 ChangeType(DesktopMediaID::TYPE_SCREEN); |
| 413 |
| 414 NSArray* items = [controller_ screenItems]; |
| 415 |
| 416 AddScreen(0); |
| 417 screen_list_->SetSourceThumbnail(0); |
| 418 EXPECT_EQ(1U, [items count]); |
| 419 EXPECT_EQ(nil, [[items objectAtIndex:0] imageTitle]); |
| 420 |
| 421 AddScreen(1); |
| 422 screen_list_->SetSourceThumbnail(1); |
| 423 EXPECT_EQ(2U, [items count]); |
| 424 EXPECT_NE(nil, [[items objectAtIndex:0] imageTitle]); |
| 425 EXPECT_NE(nil, [[items objectAtIndex:1] imageTitle]); |
| 426 } |
OLD | NEW |