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

Unified Diff: chrome/browser/push_messaging/push_messaging_notification_manager_unittest.cc

Issue 1467573003: PushMessagingNotificationManager: extract IsTabVisible and test it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/push_messaging/push_messaging_notification_manager_unittest.cc
diff --git a/chrome/browser/push_messaging/push_messaging_notification_manager_unittest.cc b/chrome/browser/push_messaging/push_messaging_notification_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..58ceaa1646b8375954462761329c1502518cbf9a
--- /dev/null
+++ b/chrome/browser/push_messaging/push_messaging_notification_manager_unittest.cc
@@ -0,0 +1,30 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/push_messaging/push_messaging_notification_manager.h"
+
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "chrome/test/base/testing_profile.h"
+#include "content/public/test/test_renderer_host.h"
+#include "testing/gtest/include/gtest/gtest.h"
Peter Beverloo 2015/11/23 13:14:25 +url/gurl.h
Michael van Ouwerkerk 2015/11/23 13:25:09 Done.
+
+class PushMessagingNotificationManagerTest
+ : public ChromeRenderViewHostTestHarness {};
+
+TEST_F(PushMessagingNotificationManagerTest, IsTabVisible) {
+ PushMessagingNotificationManager manager(profile());
+ GURL origin("https://google.com/");
+ NavigateAndCommit(origin);
+
+ EXPECT_FALSE(manager.IsTabVisible(profile(), nullptr, origin));
+ EXPECT_FALSE(manager.IsTabVisible(profile(), web_contents(),
+ GURL("https://chrome.com/")));
+ EXPECT_TRUE(manager.IsTabVisible(profile(), web_contents(), origin));
+
+ content::RenderViewHostTester::For(rvh())->SimulateWasHidden();
+ EXPECT_FALSE(manager.IsTabVisible(profile(), web_contents(), origin));
+
+ content::RenderViewHostTester::For(rvh())->SimulateWasShown();
+ EXPECT_TRUE(manager.IsTabVisible(profile(), web_contents(), origin));
+}

Powered by Google App Engine
This is Rietveld 408576698