| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/message_center/cocoa/settings_controller.h" | 5 #import "ui/message_center/cocoa/settings_controller.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #import "ui/base/test/ui_cocoa_test_helper.h" | 9 #import "ui/base/test/ui_cocoa_test_helper.h" |
| 10 #include "ui/message_center/fake_notifier_settings_provider.h" | 10 #include "ui/message_center/fake_notifier_settings_provider.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 TEST_F(CocoaTest, Basic) { | 38 TEST_F(CocoaTest, Basic) { |
| 39 std::vector<Notifier*> notifiers; | 39 std::vector<Notifier*> notifiers; |
| 40 notifiers.push_back(NewNotifier("id", "title", /*enabled=*/true)); | 40 notifiers.push_back(NewNotifier("id", "title", /*enabled=*/true)); |
| 41 notifiers.push_back(NewNotifier("id2", "other title", /*enabled=*/false)); | 41 notifiers.push_back(NewNotifier("id2", "other title", /*enabled=*/false)); |
| 42 | 42 |
| 43 FakeNotifierSettingsProvider provider(notifiers); | 43 FakeNotifierSettingsProvider provider(notifiers); |
| 44 | 44 |
| 45 scoped_nsobject<MCSettingsController> controller( | 45 base::scoped_nsobject<MCSettingsController> controller( |
| 46 [[MCSettingsController alloc] initWithProvider:&provider]); | 46 [[MCSettingsController alloc] initWithProvider:&provider]); |
| 47 [controller view]; | 47 [controller view]; |
| 48 | 48 |
| 49 EXPECT_EQ(notifiers.size(), [controller scrollViewItemCount]); | 49 EXPECT_EQ(notifiers.size(), [controller scrollViewItemCount]); |
| 50 | 50 |
| 51 STLDeleteElements(¬ifiers); | 51 STLDeleteElements(¬ifiers); |
| 52 } | 52 } |
| 53 | 53 |
| 54 TEST_F(CocoaTest, Toggle) { | 54 TEST_F(CocoaTest, Toggle) { |
| 55 std::vector<Notifier*> notifiers; | 55 std::vector<Notifier*> notifiers; |
| 56 notifiers.push_back(NewNotifier("id", "title", /*enabled=*/true)); | 56 notifiers.push_back(NewNotifier("id", "title", /*enabled=*/true)); |
| 57 notifiers.push_back(NewNotifier("id2", "other title", /*enabled=*/false)); | 57 notifiers.push_back(NewNotifier("id2", "other title", /*enabled=*/false)); |
| 58 | 58 |
| 59 FakeNotifierSettingsProvider provider(notifiers); | 59 FakeNotifierSettingsProvider provider(notifiers); |
| 60 | 60 |
| 61 scoped_nsobject<MCSettingsController> controller( | 61 base::scoped_nsobject<MCSettingsController> controller( |
| 62 [[MCSettingsController alloc] initWithProvider:&provider]); | 62 [[MCSettingsController alloc] initWithProvider:&provider]); |
| 63 [controller view]; | 63 [controller view]; |
| 64 | 64 |
| 65 NSButton* toggleSecond = [controller bottomMostButton]; | 65 NSButton* toggleSecond = [controller bottomMostButton]; |
| 66 | 66 |
| 67 [toggleSecond performClick:nil]; | 67 [toggleSecond performClick:nil]; |
| 68 EXPECT_TRUE(provider.WasEnabled(*notifiers.back())); | 68 EXPECT_TRUE(provider.WasEnabled(*notifiers.back())); |
| 69 | 69 |
| 70 [toggleSecond performClick:nil]; | 70 [toggleSecond performClick:nil]; |
| 71 EXPECT_FALSE(provider.WasEnabled(*notifiers.back())); | 71 EXPECT_FALSE(provider.WasEnabled(*notifiers.back())); |
| 72 | 72 |
| 73 EXPECT_EQ(0, provider.closed_called_count()); | 73 EXPECT_EQ(0, provider.closed_called_count()); |
| 74 controller.reset(); | 74 controller.reset(); |
| 75 EXPECT_EQ(1, provider.closed_called_count()); | 75 EXPECT_EQ(1, provider.closed_called_count()); |
| 76 | 76 |
| 77 STLDeleteElements(¬ifiers); | 77 STLDeleteElements(¬ifiers); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace message_center | 80 } // namespace message_center |
| OLD | NEW |