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

Side by Side Diff: chrome/browser/notifications/notification_exceptions_table_model_unittest.cc

Issue 7655019: Migrate Obsolete NotificationsSettings and remove content_settings::NotificationsProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 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) 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/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 scoped_ptr<NotificationExceptionsTableModel> model_; 53 scoped_ptr<NotificationExceptionsTableModel> model_;
54 DesktopNotificationService* service_; 54 DesktopNotificationService* service_;
55 }; 55 };
56 56
57 TEST_F(NotificationExceptionsTableModelTest, CanCreate) { 57 TEST_F(NotificationExceptionsTableModelTest, CanCreate) {
58 EXPECT_EQ(0, model_->RowCount()); 58 EXPECT_EQ(0, model_->RowCount());
59 } 59 }
60 60
61 TEST_F(NotificationExceptionsTableModelTest, RemoveAll) { 61 TEST_F(NotificationExceptionsTableModelTest, RemoveAll) {
62 FillData(); 62 FillData();
63 EXPECT_EQ(2u, service_->GetAllowedOrigins().size()); 63 HostContentSettingsMap::SettingsForOneType settings;
64 EXPECT_EQ(3u, service_->GetBlockedOrigins().size()); 64 service_->GetNotificationsSettings(&settings);
65 EXPECT_EQ(5u, settings.size());
65 EXPECT_EQ(5, model_->RowCount()); 66 EXPECT_EQ(5, model_->RowCount());
66 67
67 model_->RemoveAll(); 68 model_->RemoveAll();
68 EXPECT_EQ(0, model_->RowCount()); 69 EXPECT_EQ(0, model_->RowCount());
69 70
70 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); 71 service_->GetNotificationsSettings(&settings);
71 EXPECT_EQ(0u, service_->GetBlockedOrigins().size()); 72 EXPECT_EQ(0u, settings.size());
72 } 73 }
73 74
74 TEST_F(NotificationExceptionsTableModelTest, AlphabeticalOrder) { 75 TEST_F(NotificationExceptionsTableModelTest, AlphabeticalOrder) {
75 FillData(); 76 FillData();
76 EXPECT_EQ(5, model_->RowCount()); 77 EXPECT_EQ(5, model_->RowCount());
77 78
78 EXPECT_EQ(ASCIIToUTF16("allowed.com"), 79 EXPECT_EQ(ASCIIToUTF16("http://allowed.com:80"),
79 model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER)); 80 model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER));
80 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON), 81 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON),
81 model_->GetText(0, IDS_EXCEPTIONS_ACTION_HEADER)); 82 model_->GetText(0, IDS_EXCEPTIONS_ACTION_HEADER));
82 83
83 EXPECT_EQ(ASCIIToUTF16("denied.com"), 84 EXPECT_EQ(ASCIIToUTF16("http://denied.com:80"),
84 model_->GetText(1, IDS_EXCEPTIONS_HOSTNAME_HEADER)); 85 model_->GetText(1, IDS_EXCEPTIONS_HOSTNAME_HEADER));
85 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), 86 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON),
86 model_->GetText(1, IDS_EXCEPTIONS_ACTION_HEADER)); 87 model_->GetText(1, IDS_EXCEPTIONS_ACTION_HEADER));
87 88
88 EXPECT_EQ(ASCIIToUTF16("denied2.com"), 89 EXPECT_EQ(ASCIIToUTF16("http://denied2.com:80"),
89 model_->GetText(2, IDS_EXCEPTIONS_HOSTNAME_HEADER)); 90 model_->GetText(2, IDS_EXCEPTIONS_HOSTNAME_HEADER));
90 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), 91 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON),
91 model_->GetText(2, IDS_EXCEPTIONS_ACTION_HEADER)); 92 model_->GetText(2, IDS_EXCEPTIONS_ACTION_HEADER));
92 93
93 EXPECT_EQ(ASCIIToUTF16("e-allowed2.com"), 94 EXPECT_EQ(ASCIIToUTF16("http://e-allowed2.com:80"),
94 model_->GetText(3, IDS_EXCEPTIONS_HOSTNAME_HEADER)); 95 model_->GetText(3, IDS_EXCEPTIONS_HOSTNAME_HEADER));
95 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON), 96 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON),
96 model_->GetText(3, IDS_EXCEPTIONS_ACTION_HEADER)); 97 model_->GetText(3, IDS_EXCEPTIONS_ACTION_HEADER));
97 98
98 EXPECT_EQ(ASCIIToUTF16("f-denied3.com"), 99 EXPECT_EQ(ASCIIToUTF16("http://f-denied3.com:80"),
99 model_->GetText(4, IDS_EXCEPTIONS_HOSTNAME_HEADER)); 100 model_->GetText(4, IDS_EXCEPTIONS_HOSTNAME_HEADER));
100 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), 101 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON),
101 model_->GetText(4, IDS_EXCEPTIONS_ACTION_HEADER)); 102 model_->GetText(4, IDS_EXCEPTIONS_ACTION_HEADER));
102 } 103 }
103 104
104 TEST_F(NotificationExceptionsTableModelTest, RemoveRows) { 105 TEST_F(NotificationExceptionsTableModelTest, RemoveRows) {
105 FillData(); 106 FillData();
106 EXPECT_EQ(5, model_->RowCount()); 107 EXPECT_EQ(5, model_->RowCount());
107 108
108 { 109 {
109 RemoveRowsTableModel::Rows rows; 110 RemoveRowsTableModel::Rows rows;
110 rows.insert(0); // allowed.com 111 rows.insert(0); // allowed.com
111 rows.insert(3); // e-allowed2.com 112 rows.insert(3); // e-allowed2.com
112 model_->RemoveRows(rows); 113 model_->RemoveRows(rows);
113 } 114 }
114 EXPECT_EQ(3, model_->RowCount()); 115 EXPECT_EQ(3, model_->RowCount());
115 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); 116
116 EXPECT_EQ(3u, service_->GetBlockedOrigins().size()); 117 HostContentSettingsMap::SettingsForOneType settings;
118 service_->GetNotificationsSettings(&settings);
119 EXPECT_EQ(3u, settings.size());
117 120
118 { 121 {
119 RemoveRowsTableModel::Rows rows; 122 RemoveRowsTableModel::Rows rows;
120 rows.insert(0); 123 rows.insert(0);
121 rows.insert(1); 124 rows.insert(1);
122 rows.insert(2); 125 rows.insert(2);
123 model_->RemoveRows(rows); 126 model_->RemoveRows(rows);
124 } 127 }
125 EXPECT_EQ(0, model_->RowCount()); 128 EXPECT_EQ(0, model_->RowCount());
126 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); 129 service_->GetNotificationsSettings(&settings);
127 EXPECT_EQ(0u, service_->GetBlockedOrigins().size()); 130 EXPECT_EQ(0u, settings.size());
128 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698