| 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
|
|
|