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"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace browser_watcher
{
16 void OnEndSession(bool* called
, LPARAM
* out_lparam
, LPARAM lparam
) {
21 } // namespace browser_watcher
23 TEST(EndSessionWatcherWindowTest
, NoCallbackOnDestruction
) {
25 bool was_called
= false;
28 EndSessionWatcherWindow
watcher_window(
29 base::Bind(&OnEndSession
, &was_called
, &lparam
));
32 EXPECT_FALSE(was_called
);
36 TEST(EndSessionWatcherWindowTest
, IssuesCallbackOnMessage
) {
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