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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa_unittest.mm

Issue 10911242: make media gallery directory tooltips in media gallery config dialog absolute paths (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: +! Created 8 years, 3 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 | 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 "base/string_number_conversions.h"
6 #include "chrome/browser/system_monitor/media_storage_util.h"
5 #include "chrome/browser/media_gallery/media_galleries_dialog_controller_mock.h" 7 #include "chrome/browser/media_gallery/media_galleries_dialog_controller_mock.h"
6 #include "chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h" 8 #include "chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h"
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
9 using ::testing::_; 11 using ::testing::_;
10 using ::testing::NiceMock; 12 using ::testing::NiceMock;
11 using ::testing::Return; 13 using ::testing::Return;
12 using ::testing::ReturnRef; 14 using ::testing::ReturnRef;
13 15
14 namespace chrome { 16 namespace chrome {
15 17
18 MediaGalleryPrefInfo MakePrefInfoForTesting(MediaGalleryPrefId pref_id) {
19 MediaGalleryPrefInfo gallery;
20 gallery.pref_id = pref_id;
21 gallery.device_id =
22 MediaStorageUtil::MakeDeviceId(MediaStorageUtil::FIXED_MASS_STORAGE,
23 base::Int64ToString(pref_id));
24 return gallery;
25 }
26
16 class MediaGalleriesDialogTest : public testing::Test { 27 class MediaGalleriesDialogTest : public testing::Test {
17 }; 28 };
18 29
19 // Tests that checkboxes are initialized according to the contents of 30 // Tests that checkboxes are initialized according to the contents of
20 // permissions(). 31 // permissions().
21 TEST_F(MediaGalleriesDialogTest, InitializeCheckboxes) { 32 TEST_F(MediaGalleriesDialogTest, InitializeCheckboxes) {
22 NiceMock<MediaGalleriesDialogControllerMock> controller; 33 NiceMock<MediaGalleriesDialogControllerMock> controller;
23 34
24 MediaGalleriesDialogController::KnownGalleryPermissions permissions; 35 MediaGalleriesDialogController::KnownGalleryPermissions permissions;
25 MediaGalleryPrefInfo gallery1; 36 MediaGalleryPrefInfo gallery1 = MakePrefInfoForTesting(1);
26 gallery1.device_id = "/a";
27 permissions[1] = MediaGalleriesDialogController::GalleryPermission( 37 permissions[1] = MediaGalleriesDialogController::GalleryPermission(
28 gallery1, true); 38 gallery1, true);
29 MediaGalleryPrefInfo gallery2; 39 MediaGalleryPrefInfo gallery2 = MakePrefInfoForTesting(2);
30 gallery2.device_id = "/b";
31 permissions[2] = MediaGalleriesDialogController::GalleryPermission( 40 permissions[2] = MediaGalleriesDialogController::GalleryPermission(
32 gallery2, false); 41 gallery2, false);
33 EXPECT_CALL(controller, permissions()). 42 EXPECT_CALL(controller, permissions()).
34 WillRepeatedly(ReturnRef(permissions)); 43 WillRepeatedly(ReturnRef(permissions));
35 44
36 // Initializing checkboxes should not cause them to be toggled. 45 // Initializing checkboxes should not cause them to be toggled.
37 EXPECT_CALL(controller, DidToggleGallery(_, _)). 46 EXPECT_CALL(controller, DidToggleGallery(_, _)).
38 Times(0); 47 Times(0);
39 48
40 scoped_ptr<MediaGalleriesDialogCocoa> dialog( 49 scoped_ptr<MediaGalleriesDialogCocoa> dialog(
41 static_cast<MediaGalleriesDialogCocoa*>( 50 static_cast<MediaGalleriesDialogCocoa*>(
42 MediaGalleriesDialog::Create(&controller))); 51 MediaGalleriesDialog::Create(&controller)));
43 EXPECT_EQ(2U, [dialog->checkboxes_ count]); 52 EXPECT_EQ(2U, [dialog->checkboxes_ count]);
44 53
45 // Note that checkboxes_ is sorted from bottom up. 54 // Note that checkboxes_ is sorted from bottom up.
46 NSButton* checkbox1 = [dialog->checkboxes_ objectAtIndex:1]; 55 NSButton* checkbox1 = [dialog->checkboxes_ objectAtIndex:1];
47 EXPECT_EQ([checkbox1 state], NSOnState); 56 EXPECT_EQ([checkbox1 state], NSOnState);
48 57
49 NSButton* checkbox2 = [dialog->checkboxes_ objectAtIndex:0]; 58 NSButton* checkbox2 = [dialog->checkboxes_ objectAtIndex:0];
50 EXPECT_EQ([checkbox2 state], NSOffState); 59 EXPECT_EQ([checkbox2 state], NSOffState);
51 } 60 }
52 61
53 // Tests that toggling checkboxes updates the controller. 62 // Tests that toggling checkboxes updates the controller.
54 TEST_F(MediaGalleriesDialogTest, ToggleCheckboxes) { 63 TEST_F(MediaGalleriesDialogTest, ToggleCheckboxes) {
55 NiceMock<MediaGalleriesDialogControllerMock> controller; 64 NiceMock<MediaGalleriesDialogControllerMock> controller;
56 65
57 MediaGalleriesDialogController::KnownGalleryPermissions permissions; 66 MediaGalleriesDialogController::KnownGalleryPermissions permissions;
58 MediaGalleryPrefInfo gallery; 67 MediaGalleryPrefInfo gallery = MakePrefInfoForTesting(1);
59 permissions[1] = MediaGalleriesDialogController::GalleryPermission( 68 permissions[1] = MediaGalleriesDialogController::GalleryPermission(
60 gallery, true); 69 gallery, true);
61 EXPECT_CALL(controller, permissions()). 70 EXPECT_CALL(controller, permissions()).
62 WillRepeatedly(ReturnRef(permissions)); 71 WillRepeatedly(ReturnRef(permissions));
63 72
64 scoped_ptr<MediaGalleriesDialogCocoa> dialog( 73 scoped_ptr<MediaGalleriesDialogCocoa> dialog(
65 static_cast<MediaGalleriesDialogCocoa*>( 74 static_cast<MediaGalleriesDialogCocoa*>(
66 MediaGalleriesDialog::Create(&controller))); 75 MediaGalleriesDialog::Create(&controller)));
67 EXPECT_EQ(1U, [dialog->checkboxes_ count]); 76 EXPECT_EQ(1U, [dialog->checkboxes_ count]);
68 77
(...skipping 18 matching lines...) Expand all
87 EXPECT_CALL(controller, permissions()). 96 EXPECT_CALL(controller, permissions()).
88 WillRepeatedly(ReturnRef(permissions)); 97 WillRepeatedly(ReturnRef(permissions));
89 98
90 scoped_ptr<MediaGalleriesDialogCocoa> dialog( 99 scoped_ptr<MediaGalleriesDialogCocoa> dialog(
91 static_cast<MediaGalleriesDialogCocoa*>( 100 static_cast<MediaGalleriesDialogCocoa*>(
92 MediaGalleriesDialog::Create(&controller))); 101 MediaGalleriesDialog::Create(&controller)));
93 102
94 EXPECT_EQ(0U, [dialog->checkboxes_ count]); 103 EXPECT_EQ(0U, [dialog->checkboxes_ count]);
95 CGFloat old_container_height = NSHeight([dialog->checkbox_container_ frame]); 104 CGFloat old_container_height = NSHeight([dialog->checkbox_container_ frame]);
96 105
97 MediaGalleryPrefInfo gallery1; 106 MediaGalleryPrefInfo gallery1 = MakePrefInfoForTesting(1);
98 gallery1.device_id = "/a";
99 dialog->UpdateGallery(&gallery1, true); 107 dialog->UpdateGallery(&gallery1, true);
100 EXPECT_EQ(1U, [dialog->checkboxes_ count]); 108 EXPECT_EQ(1U, [dialog->checkboxes_ count]);
101 109
102 // The checkbox container should be taller. 110 // The checkbox container should be taller.
103 CGFloat new_container_height = NSHeight([dialog->checkbox_container_ frame]); 111 CGFloat new_container_height = NSHeight([dialog->checkbox_container_ frame]);
104 EXPECT_GT(new_container_height, old_container_height); 112 EXPECT_GT(new_container_height, old_container_height);
105 old_container_height = new_container_height; 113 old_container_height = new_container_height;
106 114
107 MediaGalleryPrefInfo gallery2; 115 MediaGalleryPrefInfo gallery2 = MakePrefInfoForTesting(2);
108 gallery2.device_id = "/b";
109 dialog->UpdateGallery(&gallery2, true); 116 dialog->UpdateGallery(&gallery2, true);
110 EXPECT_EQ(2U, [dialog->checkboxes_ count]); 117 EXPECT_EQ(2U, [dialog->checkboxes_ count]);
111 118
112 // The checkbox container should be taller. 119 // The checkbox container should be taller.
113 new_container_height = NSHeight([dialog->checkbox_container_ frame]); 120 new_container_height = NSHeight([dialog->checkbox_container_ frame]);
114 EXPECT_GT(new_container_height, old_container_height); 121 EXPECT_GT(new_container_height, old_container_height);
115 old_container_height = new_container_height; 122 old_container_height = new_container_height;
116 123
117 dialog->UpdateGallery(&gallery2, false); 124 dialog->UpdateGallery(&gallery2, false);
118 EXPECT_EQ(2U, [dialog->checkboxes_ count]); 125 EXPECT_EQ(2U, [dialog->checkboxes_ count]);
119 126
120 // The checkbox container height should not have changed. 127 // The checkbox container height should not have changed.
121 new_container_height = NSHeight([dialog->checkbox_container_ frame]); 128 new_container_height = NSHeight([dialog->checkbox_container_ frame]);
122 EXPECT_EQ(new_container_height, old_container_height); 129 EXPECT_EQ(new_container_height, old_container_height);
123 } 130 }
124 131
125 } // namespace chrome 132 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698