summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-11 03:52:08 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-11 03:52:08 +0000
commitbfb6f7b33567f97b32429c7adf11be650daa0a4e (patch)
tree5182c0dc0b9f84f1455a4fa3766617f27abdd0c9
parent0eb0e874e21ae0ce8bcf0764b5168910d6dfae9b (diff)
downloadchromium_src-bfb6f7b33567f97b32429c7adf11be650daa0a4e.zip
chromium_src-bfb6f7b33567f97b32429c7adf11be650daa0a4e.tar.gz
chromium_src-bfb6f7b33567f97b32429c7adf11be650daa0a4e.tar.bz2
Removes unnecessary GetDefaultProfile from sync_notifier.
ChromeNotifierDelegateBrowserTest uses GetDefaultProfile() but actually this should be a TestingProfile and this can now be a unit test rather than a browser test. Also using TestingProfile enables to run some disabled tests. By the way -- OS_LINUX && USE_AURA may match with OS_CHROMEOS. BUG=322682 R=skuhne@chromium.org, petewil@chromium.org TEST=unit_tests Review URL: https://codereview.chromium.org/111893008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240005 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_unittest.cc (renamed from chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc)70
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/chrome_tests_unit.gypi1
3 files changed, 34 insertions, 38 deletions
diff --git a/chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc b/chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_unittest.cc
index 0dd6e60..3e2ce4c 100644
--- a/chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc
+++ b/chrome/browser/notifications/sync_notifier/chrome_notifier_delegate_unittest.cc
@@ -8,26 +8,22 @@
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
#include "chrome/browser/notifications/sync_notifier/sync_notifier_test_utils.h"
#include "chrome/browser/notifications/sync_notifier/synced_notification.h"
-#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/test_utils.h"
#include "sync/api/sync_change.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/message_center/notification_types.h"
const char kTestNotificationId[] = "SomeRandomNotificationId";
class StubChromeNotifierService : public notifier::ChromeNotifierService {
public:
- StubChromeNotifierService()
- : ChromeNotifierService(ProfileManager::GetDefaultProfile(), NULL) {}
+ explicit StubChromeNotifierService(Profile* profile)
+ : ChromeNotifierService(profile, NULL) {}
virtual ~StubChromeNotifierService() {}
@@ -70,22 +66,34 @@ class StubChromeNotifierService : public notifier::ChromeNotifierService {
ScopedVector<notifier::SyncedNotification> owned_notifications_;
};
-class ChromeNotifierDelegateBrowserTest : public InProcessBrowserTest {};
+class ChromeNotifierDelegateTest : public BrowserWithTestWindowTest {
+ public:
+ ChromeNotifierDelegateTest() {}
+ virtual ~ChromeNotifierDelegateTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ BrowserWithTestWindowTest::SetUp();
+ notifier_.reset(new StubChromeNotifierService(profile()));
+ }
+
+ virtual void TearDown() OVERRIDE {
+ notifier_.reset();
+ BrowserWithTestWindowTest::TearDown();
+ }
-// Test will not have access to the browser profile on linux aura
-#if defined(OS_LINUX) && defined(USE_AURA)
-#define MAYBE_ClickTest \
- DISABLED_ClickTest
-#else
-#define MAYBE_ClickTest \
- ClickTest
-#endif
+ protected:
+ StubChromeNotifierService* notifier() { return notifier_.get(); }
+
+ private:
+ scoped_ptr<StubChromeNotifierService> notifier_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeNotifierDelegateTest);
+};
-IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest, MAYBE_ClickTest) {
+TEST_F(ChromeNotifierDelegateTest, ClickTest) {
std::string id(kTestNotificationId);
- StubChromeNotifierService notifier;
scoped_refptr<notifier::ChromeNotifierDelegate> delegate(
- new notifier::ChromeNotifierDelegate(id, &notifier));
+ new notifier::ChromeNotifierDelegate(id, notifier()));
// Set up an observer to wait for the navigation
content::WindowedNotificationObserver observer(
@@ -104,21 +112,10 @@ IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest, MAYBE_ClickTest) {
ASSERT_EQ(url, tab->GetController().GetActiveEntry()->GetVirtualURL());
}
-// Test will not have access to the browser profile on linux aura.
-#if defined(OS_LINUX) && defined(USE_AURA)
-#define MAYBE_ButtonClickTest \
- DISABLED_ButtonClickTest
-#else
-#define MAYBE_ButtonClickTest \
- ButtonClickTest
-#endif
-
-IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest,
- MAYBE_ButtonClickTest) {
+TEST_F(ChromeNotifierDelegateTest, ButtonClickTest) {
std::string id(kTestNotificationId);
- StubChromeNotifierService notifier;
scoped_refptr<notifier::ChromeNotifierDelegate> delegate(
- new notifier::ChromeNotifierDelegate(id, &notifier));
+ new notifier::ChromeNotifierDelegate(id, notifier()));
// Set up an observer to wait for the navigation
content::WindowedNotificationObserver observer(
@@ -148,15 +145,14 @@ IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest,
ASSERT_EQ(url2, tab->GetController().GetActiveEntry()->GetVirtualURL());
}
-IN_PROC_BROWSER_TEST_F(ChromeNotifierDelegateBrowserTest, CloseTest) {
+TEST_F(ChromeNotifierDelegateTest, CloseTest) {
std::string id(kTestNotificationId);
- StubChromeNotifierService notifier;
scoped_refptr<notifier::ChromeNotifierDelegate> delegate(
- new notifier::ChromeNotifierDelegate(id, &notifier));
+ new notifier::ChromeNotifierDelegate(id, notifier()));
delegate->Close(false);
- ASSERT_EQ("", notifier.read_id());
+ ASSERT_EQ("", notifier()->read_id());
delegate->Close(true);
- ASSERT_EQ(kTestNotificationId, notifier.read_id());
+ ASSERT_EQ(kTestNotificationId, notifier()->read_id());
}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index b970cd7..8b3fdfa 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1300,7 +1300,6 @@
'browser/net/websocket_browsertest.cc',
'browser/notifications/login_state_notification_blocker_chromeos_browsertest.cc',
'browser/notifications/message_center_notifications_browsertest.cc',
- 'browser/notifications/sync_notifier/chrome_notifier_delegate_browsertest.cc',
'browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc',
'browser/notifications/sync_notifier/sync_notifier_test_utils.cc',
'browser/notifications/sync_notifier/sync_notifier_test_utils.h',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 0247750..83c9a61 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1061,6 +1061,7 @@
'browser/notifications/message_center_notifications_unittest_win.cc',
'browser/notifications/message_center_settings_controller_unittest.cc',
'browser/notifications/multi_user_notification_blocker_chromeos_unittest.cc',
+ 'browser/notifications/sync_notifier/chrome_notifier_delegate_unittest.cc',
'browser/notifications/sync_notifier/chrome_notifier_service_unittest.cc',
'browser/notifications/sync_notifier/synced_notification_unittest.cc',
'browser/notifications/sync_notifier/sync_notifier_test_utils.cc',