OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "util/win/session_end_watcher.h" |
| 16 |
| 17 #include "gtest/gtest.h" |
| 18 #include "test/errors.h" |
| 19 |
| 20 namespace crashpad { |
| 21 namespace test { |
| 22 namespace { |
| 23 |
| 24 class SessionEndWatcherTest final : public SessionEndWatcher { |
| 25 public: |
| 26 SessionEndWatcherTest() : SessionEndWatcher(), called_(false) {} |
| 27 |
| 28 ~SessionEndWatcherTest() override {} |
| 29 |
| 30 void Run() { |
| 31 WaitForStart(); |
| 32 |
| 33 HWND window = GetWindow(); |
| 34 ASSERT_TRUE(window); |
| 35 EXPECT_TRUE(PostMessage(window, WM_ENDSESSION, 1, 0)); |
| 36 |
| 37 WaitForStop(); |
| 38 |
| 39 EXPECT_TRUE(called_); |
| 40 } |
| 41 |
| 42 private: |
| 43 // SessionEndWatcher: |
| 44 void SessionEnding() override { called_ = true; } |
| 45 |
| 46 bool called_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(SessionEndWatcherTest); |
| 49 }; |
| 50 |
| 51 TEST(SessionEndWatcher, SessionEndWatcher) { |
| 52 SessionEndWatcherTest test; |
| 53 test.Run(); |
| 54 } |
| 55 |
| 56 TEST(SessionEndWatcher, DoNothing) { |
| 57 SessionEndWatcherTest test; |
| 58 } |
| 59 |
| 60 } // namespace |
| 61 } // namespace test |
| 62 } // namespace crashpad |
OLD | NEW |