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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4 #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.
5
6 #include <windows.h>
7
8 #include "base/bind.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace browser_watcher {
12
13 namespace {
14
15 class EndSessionWatcherWindowTest : public testing::Test {
16 public:
17 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.
18 *called = true;
19 *out_lparam = lparam;
20 }
21 };
22
23 } // namespace browser_watcher
24
25 TEST_F(EndSessionWatcherWindowTest, NoCallbackOnDestruction) {
26 LPARAM lparam = 0;
27 bool was_called = false;
28
29 {
30 EndSessionWatcherWindow watcher_window(
31 base::Bind(&EndSessionWatcherWindowTest::OnEndSession,
32 base::Unretained(this), &was_called, &lparam));
33 }
34
35 EXPECT_FALSE(was_called);
36 EXPECT_EQ(lparam, 0);
37 }
38
39 TEST_F(EndSessionWatcherWindowTest, IssuesCallbackOnMessage) {
40 LPARAM lparam = 0;
41 bool was_called = false;
42
43 EndSessionWatcherWindow watcher_window(
44 base::Bind(&EndSessionWatcherWindowTest::OnEndSession,
45 base::Unretained(this), &was_called, &lparam));
46
47 ::SendMessage(watcher_window.window(), WM_ENDSESSION, TRUE, 0xCAFEBABE);
48
49 EXPECT_TRUE(was_called);
50 EXPECT_EQ(lparam, 0xCAFEBABE);
51 }
52
53 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698