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_de precated.h" |
tapted
2016/06/20 12:18:36
You need to test the new interface as well - this
qiangchen
2016/06/21 23:31:28
Yep, I delay that after your initial code review,
| |
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 "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
14 #include "testing/gtest_mac.h" | 14 #include "testing/gtest_mac.h" |
15 | 15 |
16 @interface DesktopMediaPickerController (ExposedForTesting) | 16 @interface DesktopMediaPickerControllerDeprecated (ExposedForTesting) |
17 - (IKImageBrowserView*)sourceBrowser; | 17 - (IKImageBrowserView*)sourceBrowser; |
18 - (NSButton*)shareButton; | 18 - (NSButton*)shareButton; |
19 - (NSButton*)audioShareCheckbox; | 19 - (NSButton*)audioShareCheckbox; |
20 - (NSArray*)items; | 20 - (NSArray*)items; |
21 @end | 21 @end |
22 | 22 |
23 @implementation DesktopMediaPickerController (ExposedForTesting) | 23 @implementation DesktopMediaPickerControllerDeprecated (ExposedForTesting) |
24 - (IKImageBrowserView*)sourceBrowser { | 24 - (IKImageBrowserView*)sourceBrowser { |
25 return sourceBrowser_; | 25 return sourceBrowser_; |
26 } | 26 } |
27 | 27 |
28 - (NSButton*)shareButton { | 28 - (NSButton*)shareButton { |
29 return shareButton_; | 29 return shareButton_; |
30 } | 30 } |
31 | 31 |
32 - (NSButton*)cancelButton { | 32 - (NSButton*)cancelButton { |
33 return cancelButton_; | 33 return cancelButton_; |
(...skipping 16 matching lines...) Expand all Loading... | |
50 CocoaTest::SetUp(); | 50 CocoaTest::SetUp(); |
51 | 51 |
52 screen_list_ = new FakeDesktopMediaList(); | 52 screen_list_ = new FakeDesktopMediaList(); |
53 window_list_ = new FakeDesktopMediaList(); | 53 window_list_ = new FakeDesktopMediaList(); |
54 tab_list_ = new FakeDesktopMediaList(); | 54 tab_list_ = new FakeDesktopMediaList(); |
55 | 55 |
56 DesktopMediaPicker::DoneCallback callback = | 56 DesktopMediaPicker::DoneCallback callback = |
57 base::Bind(&DesktopMediaPickerControllerTest::OnResult, | 57 base::Bind(&DesktopMediaPickerControllerTest::OnResult, |
58 base::Unretained(this)); | 58 base::Unretained(this)); |
59 | 59 |
60 controller_.reset([[DesktopMediaPickerController alloc] | 60 controller_.reset([[DesktopMediaPickerControllerDeprecated alloc] |
61 initWithScreenList:std::unique_ptr<DesktopMediaList>(screen_list_) | 61 initWithScreenList:std::unique_ptr<DesktopMediaList>(screen_list_) |
62 windowList:std::unique_ptr<DesktopMediaList>(window_list_) | 62 windowList:std::unique_ptr<DesktopMediaList>(window_list_) |
63 tabList:std::unique_ptr<DesktopMediaList>(tab_list_) | 63 tabList:std::unique_ptr<DesktopMediaList>(tab_list_) |
64 parent:nil | 64 parent:nil |
65 callback:callback | 65 callback:callback |
66 appName:base::ASCIIToUTF16("Screenshare Test") | 66 appName:base::ASCIIToUTF16("Screenshare Test") |
67 targetName:base::ASCIIToUTF16("https://foo.com") | 67 targetName:base::ASCIIToUTF16("https://foo.com") |
68 requestAudio:true]); | 68 requestAudio:true]); |
69 } | 69 } |
70 | 70 |
(...skipping 15 matching lines...) Expand all Loading... | |
86 callback_called_ = true; | 86 callback_called_ = true; |
87 source_reported_ = source; | 87 source_reported_ = source; |
88 } | 88 } |
89 | 89 |
90 content::TestBrowserThreadBundle thread_bundle_; | 90 content::TestBrowserThreadBundle thread_bundle_; |
91 bool callback_called_ = false; | 91 bool callback_called_ = false; |
92 content::DesktopMediaID source_reported_; | 92 content::DesktopMediaID source_reported_; |
93 FakeDesktopMediaList* screen_list_ = nullptr; | 93 FakeDesktopMediaList* screen_list_ = nullptr; |
94 FakeDesktopMediaList* window_list_ = nullptr; | 94 FakeDesktopMediaList* window_list_ = nullptr; |
95 FakeDesktopMediaList* tab_list_ = nullptr; | 95 FakeDesktopMediaList* tab_list_ = nullptr; |
96 base::scoped_nsobject<DesktopMediaPickerController> controller_; | 96 base::scoped_nsobject<DesktopMediaPickerControllerDeprecated> controller_; |
97 }; | 97 }; |
98 | 98 |
99 TEST_F(DesktopMediaPickerControllerTest, ShowAndDismiss) { | 99 TEST_F(DesktopMediaPickerControllerTest, ShowAndDismiss) { |
100 [controller_ showWindow:nil]; | 100 [controller_ showWindow:nil]; |
101 | 101 |
102 window_list_->AddSource(0); | 102 window_list_->AddSource(0); |
103 window_list_->AddSource(1); | 103 window_list_->AddSource(1); |
104 window_list_->SetSourceThumbnail(1); | 104 window_list_->SetSourceThumbnail(1); |
105 | 105 |
106 NSArray* items = [controller_ items]; | 106 NSArray* items = [controller_ items]; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 index_set = [NSIndexSet indexSetWithIndex:2]; | 250 index_set = [NSIndexSet indexSetWithIndex:2]; |
251 [[controller_ sourceBrowser] setSelectionIndexes:index_set | 251 [[controller_ sourceBrowser] setSelectionIndexes:index_set |
252 byExtendingSelection:NO]; | 252 byExtendingSelection:NO]; |
253 EXPECT_EQ(YES, [checkbox isEnabled]); | 253 EXPECT_EQ(YES, [checkbox isEnabled]); |
254 | 254 |
255 index_set = [NSIndexSet indexSet]; | 255 index_set = [NSIndexSet indexSet]; |
256 [[controller_ sourceBrowser] setSelectionIndexes:index_set | 256 [[controller_ sourceBrowser] setSelectionIndexes:index_set |
257 byExtendingSelection:NO]; | 257 byExtendingSelection:NO]; |
258 EXPECT_EQ(NO, [checkbox isEnabled]); | 258 EXPECT_EQ(NO, [checkbox isEnabled]); |
259 } | 259 } |
OLD | NEW |