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

Unified Diff: components/browser_watcher/endsession_watcher_window_win_unittest.cc

Issue 843113002: EndSessionWatcherWindow implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge ToT. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/browser_watcher/endsession_watcher_window_win.cc ('k') | components/components_tests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/browser_watcher/endsession_watcher_window_win_unittest.cc
diff --git a/components/browser_watcher/endsession_watcher_window_win_unittest.cc b/components/browser_watcher/endsession_watcher_window_win_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5adce4f34718eff86d2db56e5b40ee15caef9851
--- /dev/null
+++ b/components/browser_watcher/endsession_watcher_window_win_unittest.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 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 "components/browser_watcher/endsession_watcher_window_win.h"
+
+#include <windows.h>
+
+#include "base/bind.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace browser_watcher {
+
+namespace {
+
+void OnEndSession(bool* called, LPARAM* out_lparam, LPARAM lparam) {
+ *called = true;
+ *out_lparam = lparam;
+}
+
+} // namespace browser_watcher
+
+TEST(EndSessionWatcherWindowTest, NoCallbackOnDestruction) {
+ LPARAM lparam = 0;
+ bool was_called = false;
+
+ {
+ EndSessionWatcherWindow watcher_window(
+ base::Bind(&OnEndSession, &was_called, &lparam));
+ }
+
+ EXPECT_FALSE(was_called);
+ EXPECT_EQ(lparam, 0);
+}
+
+TEST(EndSessionWatcherWindowTest, IssuesCallbackOnMessage) {
+ LPARAM lparam = 0;
+ bool was_called = false;
+
+ EndSessionWatcherWindow watcher_window(
+ base::Bind(&OnEndSession, &was_called, &lparam));
+
+ ::SendMessage(watcher_window.window(), WM_ENDSESSION, TRUE, 0xCAFEBABE);
+
+ EXPECT_TRUE(was_called);
+ EXPECT_EQ(lparam, 0xCAFEBABE);
+}
+
+} // namespace browser_watcher
« no previous file with comments | « components/browser_watcher/endsession_watcher_window_win.cc ('k') | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698