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

Unified Diff: content/common/mac/app_nap_activity_unittest.mm

Issue 2913883002: [Mac] Wrap NSUserActivity begin/end so that it can be called from common files (Closed)
Patch Set: Whitespace Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/mac/app_nap_activity.mm ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mac/app_nap_activity_unittest.mm
diff --git a/content/common/mac/app_nap_activity_unittest.mm b/content/common/mac/app_nap_activity_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..b6c367396ef20a8d14f482b9050f2289cd0421dd
--- /dev/null
+++ b/content/common/mac/app_nap_activity_unittest.mm
@@ -0,0 +1,38 @@
+// Copyright 2017 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 "content/common/mac/app_nap_activity.h"
+
+#include "testing/gtest_mac.h"
+#include "testing/platform_test.h"
+#import "third_party/ocmock/OCMock/OCMock.h"
+#include "third_party/ocmock/gtest_support.h"
+
+class AppNapActivityTest : public PlatformTest {};
+
+TEST_F(AppNapActivityTest, StoresAssertion) {
+ const NSActivityOptions expectedOptions =
+ (NSActivityUserInitiatedAllowingIdleSystemSleep |
+ NSActivityLatencyCritical) &
+ ~(NSActivitySuddenTerminationDisabled |
+ NSActivityAutomaticTerminationDisabled);
+ id processInfoMock =
+ [OCMockObject partialMockForObject:[NSProcessInfo processInfo]];
+ id assertion = @"An activity assertion";
+ [[[processInfoMock expect] andReturn:assertion]
+ beginActivityWithOptions:expectedOptions
+ reason:OCMOCK_ANY];
+
+ content::AppNapActivity activity;
+ activity.Begin();
+
+ EXPECT_OCMOCK_VERIFY(processInfoMock);
+
+ [[processInfoMock expect] endActivity:assertion];
+
+ activity.End();
+
+ EXPECT_OCMOCK_VERIFY(processInfoMock);
+ [processInfoMock stopMocking];
+}
« no previous file with comments | « content/common/mac/app_nap_activity.mm ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698