OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/notifications/notification_exceptions_table_model.h" | 5 #include "chrome/browser/notifications/notification_exceptions_table_model.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 8 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 9 #include "chrome/common/content_settings.h" |
9 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
10 #include "content/browser/browser_thread.h" | 11 #include "content/browser/browser_thread.h" |
11 #include "content/browser/renderer_host/test_render_view_host.h" | 12 #include "content/browser/renderer_host/test_render_view_host.h" |
12 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
15 | 16 |
16 class NotificationExceptionsTableModelTest : public RenderViewHostTestHarness { | 17 class NotificationExceptionsTableModelTest : public RenderViewHostTestHarness { |
17 public: | 18 public: |
18 NotificationExceptionsTableModelTest() | 19 NotificationExceptionsTableModelTest() |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 scoped_ptr<NotificationExceptionsTableModel> model_; | 54 scoped_ptr<NotificationExceptionsTableModel> model_; |
54 DesktopNotificationService* service_; | 55 DesktopNotificationService* service_; |
55 }; | 56 }; |
56 | 57 |
57 TEST_F(NotificationExceptionsTableModelTest, CanCreate) { | 58 TEST_F(NotificationExceptionsTableModelTest, CanCreate) { |
58 EXPECT_EQ(0, model_->RowCount()); | 59 EXPECT_EQ(0, model_->RowCount()); |
59 } | 60 } |
60 | 61 |
61 TEST_F(NotificationExceptionsTableModelTest, RemoveAll) { | 62 TEST_F(NotificationExceptionsTableModelTest, RemoveAll) { |
62 FillData(); | 63 FillData(); |
63 HostContentSettingsMap::SettingsForOneType settings; | 64 ContentSettingsForOneType settings; |
64 service_->GetNotificationsSettings(&settings); | 65 service_->GetNotificationsSettings(&settings); |
65 EXPECT_EQ(5u, settings.size()); | 66 EXPECT_EQ(5u, settings.size()); |
66 EXPECT_EQ(5, model_->RowCount()); | 67 EXPECT_EQ(5, model_->RowCount()); |
67 | 68 |
68 model_->RemoveAll(); | 69 model_->RemoveAll(); |
69 EXPECT_EQ(0, model_->RowCount()); | 70 EXPECT_EQ(0, model_->RowCount()); |
70 | 71 |
71 service_->GetNotificationsSettings(&settings); | 72 service_->GetNotificationsSettings(&settings); |
72 EXPECT_EQ(0u, settings.size()); | 73 EXPECT_EQ(0u, settings.size()); |
73 } | 74 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 EXPECT_EQ(5, model_->RowCount()); | 108 EXPECT_EQ(5, model_->RowCount()); |
108 | 109 |
109 { | 110 { |
110 RemoveRowsTableModel::Rows rows; | 111 RemoveRowsTableModel::Rows rows; |
111 rows.insert(0); // allowed.com | 112 rows.insert(0); // allowed.com |
112 rows.insert(3); // e-allowed2.com | 113 rows.insert(3); // e-allowed2.com |
113 model_->RemoveRows(rows); | 114 model_->RemoveRows(rows); |
114 } | 115 } |
115 EXPECT_EQ(3, model_->RowCount()); | 116 EXPECT_EQ(3, model_->RowCount()); |
116 | 117 |
117 HostContentSettingsMap::SettingsForOneType settings; | 118 ContentSettingsForOneType settings; |
118 service_->GetNotificationsSettings(&settings); | 119 service_->GetNotificationsSettings(&settings); |
119 EXPECT_EQ(3u, settings.size()); | 120 EXPECT_EQ(3u, settings.size()); |
120 | 121 |
121 { | 122 { |
122 RemoveRowsTableModel::Rows rows; | 123 RemoveRowsTableModel::Rows rows; |
123 rows.insert(0); | 124 rows.insert(0); |
124 rows.insert(1); | 125 rows.insert(1); |
125 rows.insert(2); | 126 rows.insert(2); |
126 model_->RemoveRows(rows); | 127 model_->RemoveRows(rows); |
127 } | 128 } |
128 EXPECT_EQ(0, model_->RowCount()); | 129 EXPECT_EQ(0, model_->RowCount()); |
129 service_->GetNotificationsSettings(&settings); | 130 service_->GetNotificationsSettings(&settings); |
130 EXPECT_EQ(0u, settings.size()); | 131 EXPECT_EQ(0u, settings.size()); |
131 } | 132 } |
OLD | NEW |