OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
10 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 10 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
(...skipping 56 matching lines...) Loading... |
67 EXPECT_EQ(0, model_->RowCount()); | 67 EXPECT_EQ(0, model_->RowCount()); |
68 | 68 |
69 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); | 69 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); |
70 EXPECT_EQ(0u, service_->GetBlockedOrigins().size()); | 70 EXPECT_EQ(0u, service_->GetBlockedOrigins().size()); |
71 } | 71 } |
72 | 72 |
73 TEST_F(NotificationExceptionsTableModelTest, AlphabeticalOrder) { | 73 TEST_F(NotificationExceptionsTableModelTest, AlphabeticalOrder) { |
74 FillData(); | 74 FillData(); |
75 EXPECT_EQ(5, model_->RowCount()); | 75 EXPECT_EQ(5, model_->RowCount()); |
76 | 76 |
77 EXPECT_EQ(L"allowed.com", | 77 EXPECT_EQ(ASCIIToUTF16("allowed.com"), |
78 model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER)); | 78 model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER)); |
79 EXPECT_EQ(UTF16ToWideHack( | 79 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON), |
80 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)), | |
81 model_->GetText(0, IDS_EXCEPTIONS_ACTION_HEADER)); | 80 model_->GetText(0, IDS_EXCEPTIONS_ACTION_HEADER)); |
82 | 81 |
83 EXPECT_EQ(L"denied.com", | 82 EXPECT_EQ(ASCIIToUTF16("denied.com"), |
84 model_->GetText(1, IDS_EXCEPTIONS_HOSTNAME_HEADER)); | 83 model_->GetText(1, IDS_EXCEPTIONS_HOSTNAME_HEADER)); |
85 EXPECT_EQ(UTF16ToWideHack( | 84 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), |
86 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), | |
87 model_->GetText(1, IDS_EXCEPTIONS_ACTION_HEADER)); | 85 model_->GetText(1, IDS_EXCEPTIONS_ACTION_HEADER)); |
88 | 86 |
89 EXPECT_EQ(L"denied2.com", | 87 EXPECT_EQ(ASCIIToUTF16("denied2.com"), |
90 model_->GetText(2, IDS_EXCEPTIONS_HOSTNAME_HEADER)); | 88 model_->GetText(2, IDS_EXCEPTIONS_HOSTNAME_HEADER)); |
91 EXPECT_EQ(UTF16ToWideHack( | 89 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), |
92 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), | |
93 model_->GetText(2, IDS_EXCEPTIONS_ACTION_HEADER)); | 90 model_->GetText(2, IDS_EXCEPTIONS_ACTION_HEADER)); |
94 | 91 |
95 EXPECT_EQ(L"e-allowed2.com", | 92 EXPECT_EQ(ASCIIToUTF16("e-allowed2.com"), |
96 model_->GetText(3, IDS_EXCEPTIONS_HOSTNAME_HEADER)); | 93 model_->GetText(3, IDS_EXCEPTIONS_HOSTNAME_HEADER)); |
97 EXPECT_EQ(UTF16ToWideHack( | 94 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON), |
98 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)), | |
99 model_->GetText(3, IDS_EXCEPTIONS_ACTION_HEADER)); | 95 model_->GetText(3, IDS_EXCEPTIONS_ACTION_HEADER)); |
100 | 96 |
101 EXPECT_EQ(L"f-denied3.com", | 97 EXPECT_EQ(ASCIIToUTF16("f-denied3.com"), |
102 model_->GetText(4, IDS_EXCEPTIONS_HOSTNAME_HEADER)); | 98 model_->GetText(4, IDS_EXCEPTIONS_HOSTNAME_HEADER)); |
103 EXPECT_EQ(UTF16ToWideHack( | 99 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), |
104 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), | |
105 model_->GetText(4, IDS_EXCEPTIONS_ACTION_HEADER)); | 100 model_->GetText(4, IDS_EXCEPTIONS_ACTION_HEADER)); |
106 } | 101 } |
107 | 102 |
108 TEST_F(NotificationExceptionsTableModelTest, RemoveRows) { | 103 TEST_F(NotificationExceptionsTableModelTest, RemoveRows) { |
109 FillData(); | 104 FillData(); |
110 EXPECT_EQ(5, model_->RowCount()); | 105 EXPECT_EQ(5, model_->RowCount()); |
111 | 106 |
112 { | 107 { |
113 RemoveRowsTableModel::Rows rows; | 108 RemoveRowsTableModel::Rows rows; |
114 rows.insert(0); // allowed.com | 109 rows.insert(0); // allowed.com |
115 rows.insert(3); // e-allowed2.com | 110 rows.insert(3); // e-allowed2.com |
116 model_->RemoveRows(rows); | 111 model_->RemoveRows(rows); |
117 } | 112 } |
118 EXPECT_EQ(3, model_->RowCount()); | 113 EXPECT_EQ(3, model_->RowCount()); |
119 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); | 114 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); |
120 EXPECT_EQ(3u, service_->GetBlockedOrigins().size()); | 115 EXPECT_EQ(3u, service_->GetBlockedOrigins().size()); |
121 | 116 |
122 { | 117 { |
123 RemoveRowsTableModel::Rows rows; | 118 RemoveRowsTableModel::Rows rows; |
124 rows.insert(0); | 119 rows.insert(0); |
125 rows.insert(1); | 120 rows.insert(1); |
126 rows.insert(2); | 121 rows.insert(2); |
127 model_->RemoveRows(rows); | 122 model_->RemoveRows(rows); |
128 } | 123 } |
129 EXPECT_EQ(0, model_->RowCount()); | 124 EXPECT_EQ(0, model_->RowCount()); |
130 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); | 125 EXPECT_EQ(0u, service_->GetAllowedOrigins().size()); |
131 EXPECT_EQ(0u, service_->GetBlockedOrigins().size()); | 126 EXPECT_EQ(0u, service_->GetBlockedOrigins().size()); |
132 } | 127 } |
OLD | NEW |