| Index: chrome/browser/notifications/notification_exceptions_table_model_unittest.cc
|
| diff --git a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc
|
| index a10ce71315fa6d369d2160375b0c85453cf4ba57..6919b0b903715dd62281157179c49af05dc7d44a 100644
|
| --- a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc
|
| +++ b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc
|
| @@ -4,13 +4,13 @@
|
|
|
| #include "chrome/browser/notifications/notification_exceptions_table_model.h"
|
|
|
| +#include "app/l10n_util.h"
|
| #include "chrome/browser/renderer_host/test/test_render_view_host.h"
|
| #include "chrome/test/testing_profile.h"
|
| #include "grit/generated_resources.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -class NotificationExceptionsTableModelTest
|
| - : public RenderViewHostTestHarness {
|
| +class NotificationExceptionsTableModelTest : public RenderViewHostTestHarness {
|
| public:
|
| NotificationExceptionsTableModelTest()
|
| : ui_thread_(ChromeThread::UI, MessageLoop::current()) {
|
| @@ -21,6 +21,7 @@ class NotificationExceptionsTableModelTest
|
|
|
| virtual void SetUp() {
|
| RenderViewHostTestHarness::SetUp();
|
| + service_ = profile()->GetDesktopNotificationService();
|
| ResetModel();
|
| }
|
|
|
| @@ -30,15 +31,95 @@ class NotificationExceptionsTableModelTest
|
| }
|
|
|
| virtual void ResetModel() {
|
| - model_.reset(new NotificationExceptionsTableModel(
|
| - profile()->GetDesktopNotificationService()));
|
| + model_.reset(new NotificationExceptionsTableModel(service_));
|
| + }
|
| +
|
| + virtual void FillData() {
|
| + service_->GrantPermission(GURL("http://e-allowed2.com"));
|
| + service_->GrantPermission(GURL("http://allowed.com"));
|
| +
|
| + service_->DenyPermission(GURL("http://denied2.com"));
|
| + service_->DenyPermission(GURL("http://denied.com"));
|
| + service_->DenyPermission(GURL("http://f-denied3.com"));
|
| +
|
| + ResetModel();
|
| }
|
|
|
| protected:
|
| ChromeThread ui_thread_;
|
| scoped_ptr<NotificationExceptionsTableModel> model_;
|
| + DesktopNotificationService* service_;
|
| };
|
|
|
| TEST_F(NotificationExceptionsTableModelTest, CanCreate) {
|
| EXPECT_EQ(0, model_->RowCount());
|
| }
|
| +
|
| +TEST_F(NotificationExceptionsTableModelTest, RemoveAll) {
|
| + FillData();
|
| + EXPECT_EQ(2u, service_->GetAllowedOrigins().size());
|
| + EXPECT_EQ(3u, service_->GetBlockedOrigins().size());
|
| + EXPECT_EQ(5, model_->RowCount());
|
| +
|
| + model_->RemoveAll();
|
| + EXPECT_EQ(0, model_->RowCount());
|
| +
|
| + EXPECT_EQ(0u, service_->GetAllowedOrigins().size());
|
| + EXPECT_EQ(0u, service_->GetBlockedOrigins().size());
|
| +}
|
| +
|
| +TEST_F(NotificationExceptionsTableModelTest, AlphabeticalOrder) {
|
| + FillData();
|
| + EXPECT_EQ(5, model_->RowCount());
|
| +
|
| + EXPECT_EQ(L"allowed.com",
|
| + model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER));
|
| + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON),
|
| + model_->GetText(0, IDS_EXCEPTIONS_ACTION_HEADER));
|
| +
|
| + EXPECT_EQ(L"denied.com",
|
| + model_->GetText(1, IDS_EXCEPTIONS_HOSTNAME_HEADER));
|
| + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON),
|
| + model_->GetText(1, IDS_EXCEPTIONS_ACTION_HEADER));
|
| +
|
| + EXPECT_EQ(L"denied2.com",
|
| + model_->GetText(2, IDS_EXCEPTIONS_HOSTNAME_HEADER));
|
| + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON),
|
| + model_->GetText(2, IDS_EXCEPTIONS_ACTION_HEADER));
|
| +
|
| + EXPECT_EQ(L"e-allowed2.com",
|
| + model_->GetText(3, IDS_EXCEPTIONS_HOSTNAME_HEADER));
|
| + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON),
|
| + model_->GetText(3, IDS_EXCEPTIONS_ACTION_HEADER));
|
| +
|
| + EXPECT_EQ(L"f-denied3.com",
|
| + model_->GetText(4, IDS_EXCEPTIONS_HOSTNAME_HEADER));
|
| + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON),
|
| + model_->GetText(4, IDS_EXCEPTIONS_ACTION_HEADER));
|
| +}
|
| +
|
| +TEST_F(NotificationExceptionsTableModelTest, RemoveRows) {
|
| + FillData();
|
| + EXPECT_EQ(5, model_->RowCount());
|
| +
|
| + {
|
| + RemoveRowsTableModel::Rows rows;
|
| + rows.insert(0); // allowed.com
|
| + rows.insert(3); // e-allowed2.com
|
| + model_->RemoveRows(rows);
|
| + }
|
| + EXPECT_EQ(3, model_->RowCount());
|
| + EXPECT_EQ(0u, service_->GetAllowedOrigins().size());
|
| + EXPECT_EQ(3u, service_->GetBlockedOrigins().size());
|
| +
|
| + {
|
| + RemoveRowsTableModel::Rows rows;
|
| + rows.insert(0);
|
| + rows.insert(1);
|
| + rows.insert(2);
|
| + model_->RemoveRows(rows);
|
| + }
|
| + EXPECT_EQ(0, model_->RowCount());
|
| + EXPECT_EQ(0u, service_->GetAllowedOrigins().size());
|
| + EXPECT_EQ(0u, service_->GetBlockedOrigins().size());
|
| +}
|
|
|