OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 |
| 5 #include "content/common/mac/app_nap_activity.h" |
| 6 |
| 7 #include "testing/gtest_mac.h" |
| 8 #include "testing/platform_test.h" |
| 9 #import "third_party/ocmock/OCMock/OCMock.h" |
| 10 #include "third_party/ocmock/gtest_support.h" |
| 11 |
| 12 class AppNapActivityTest : public PlatformTest {}; |
| 13 |
| 14 TEST_F(AppNapActivityTest, StoresAssertion) { |
| 15 const NSActivityOptions expectedOptions = |
| 16 (NSActivityUserInitiatedAllowingIdleSystemSleep | |
| 17 NSActivityLatencyCritical) & |
| 18 ~(NSActivitySuddenTerminationDisabled | |
| 19 NSActivityAutomaticTerminationDisabled); |
| 20 id processInfoMock = |
| 21 [OCMockObject partialMockForObject:[NSProcessInfo processInfo]]; |
| 22 id assertion = @"An activity assertion"; |
| 23 [[[processInfoMock expect] andReturn:assertion] |
| 24 beginActivityWithOptions:expectedOptions |
| 25 reason:OCMOCK_ANY]; |
| 26 |
| 27 content::AppNapActivity activity; |
| 28 activity.Begin(); |
| 29 |
| 30 EXPECT_OCMOCK_VERIFY(processInfoMock); |
| 31 |
| 32 [[processInfoMock expect] endActivity:assertion]; |
| 33 |
| 34 activity.End(); |
| 35 |
| 36 EXPECT_OCMOCK_VERIFY(processInfoMock); |
| 37 [processInfoMock stopMocking]; |
| 38 } |
OLD | NEW |