Add an OWNERS file for //chrome/browser/chromeos/login/easy_unlock
[chromium-blink-merge.git] / components / browser_watcher / endsession_watcher_window_win_unittest.cc
blob5adce4f34718eff86d2db56e5b40ee15caef9851
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/browser_watcher/endsession_watcher_window_win.h"
7 #include <windows.h>
9 #include "base/bind.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace browser_watcher {
14 namespace {
16 void OnEndSession(bool* called, LPARAM* out_lparam, LPARAM lparam) {
17 *called = true;
18 *out_lparam = lparam;
21 } // namespace browser_watcher
23 TEST(EndSessionWatcherWindowTest, NoCallbackOnDestruction) {
24 LPARAM lparam = 0;
25 bool was_called = false;
28 EndSessionWatcherWindow watcher_window(
29 base::Bind(&OnEndSession, &was_called, &lparam));
32 EXPECT_FALSE(was_called);
33 EXPECT_EQ(lparam, 0);
36 TEST(EndSessionWatcherWindowTest, IssuesCallbackOnMessage) {
37 LPARAM lparam = 0;
38 bool was_called = false;
40 EndSessionWatcherWindow watcher_window(
41 base::Bind(&OnEndSession, &was_called, &lparam));
43 ::SendMessage(watcher_window.window(), WM_ENDSESSION, TRUE, 0xCAFEBABE);
45 EXPECT_TRUE(was_called);
46 EXPECT_EQ(lparam, 0xCAFEBABE);
49 } // namespace browser_watcher