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

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: Make constructor explicit. 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
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..8cf87e09243dc1a9d4ed9093dba9220be34dc986
--- /dev/null
+++ b/components/browser_watcher/endsession_watcher_window_win_unittest.cc
@@ -0,0 +1,53 @@
+// 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"
erikwright (departed) 2015/01/13 21:01:29 blank line before
Sigurður Ásgeirsson 2015/01/13 22:41:56 Done.
+
+#include <windows.h>
+
+#include "base/bind.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace browser_watcher {
+
+namespace {
+
+class EndSessionWatcherWindowTest : public testing::Test {
+ public:
+ void OnEndSession(bool* called, LPARAM* out_lparam, LPARAM lparam) {
erikwright (departed) 2015/01/13 21:01:29 this could be a free function, and you could get r
Sigurður Ásgeirsson 2015/01/13 22:41:56 So true, so much less verbose.
+ *called = true;
+ *out_lparam = lparam;
+ }
+};
+
+} // namespace browser_watcher
+
+TEST_F(EndSessionWatcherWindowTest, NoCallbackOnDestruction) {
+ LPARAM lparam = 0;
+ bool was_called = false;
+
+ {
+ EndSessionWatcherWindow watcher_window(
+ base::Bind(&EndSessionWatcherWindowTest::OnEndSession,
+ base::Unretained(this), &was_called, &lparam));
+ }
+
+ EXPECT_FALSE(was_called);
+ EXPECT_EQ(lparam, 0);
+}
+
+TEST_F(EndSessionWatcherWindowTest, IssuesCallbackOnMessage) {
+ LPARAM lparam = 0;
+ bool was_called = false;
+
+ EndSessionWatcherWindow watcher_window(
+ base::Bind(&EndSessionWatcherWindowTest::OnEndSession,
+ base::Unretained(this), &was_called, &lparam));
+
+ ::SendMessage(watcher_window.window(), WM_ENDSESSION, TRUE, 0xCAFEBABE);
+
+ EXPECT_TRUE(was_called);
+ EXPECT_EQ(lparam, 0xCAFEBABE);
+}
+
+} // namespace browser_watcher

Powered by Google App Engine
This is Rietveld 408576698