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

Unified Diff: ios/clean/chrome/app/steps/root_coordinator+application_step_unittest.mm

Issue 2800313002: [ios] RootCoordinator and view controller. (Closed)
Patch Set: More unittests and cleanup. Created 3 years, 8 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
Index: ios/clean/chrome/app/steps/root_coordinator+application_step_unittest.mm
diff --git a/ios/clean/chrome/app/steps/root_coordinator+application_step_unittest.mm b/ios/clean/chrome/app/steps/root_coordinator+application_step_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..00a84caa6f318033ee437cc7df92066b49ab8fc4
--- /dev/null
+++ b/ios/clean/chrome/app/steps/root_coordinator+application_step_unittest.mm
@@ -0,0 +1,61 @@
+// 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.
+
+#import "ios/clean/chrome/app/steps/root_coordinator+application_step.h"
+
+#include "base/macros.h"
+#import "ios/clean/chrome/app/application_state.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+#import "third_party/ocmock/OCMock/OCMock.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace {
+
+class RootCoordinatorApplicationStepTest : public PlatformTest {
+ public:
+ RootCoordinatorApplicationStepTest() {
+ coordinator_ = [[RootCoordinator alloc] init];
+ state_ = [[ApplicationState alloc] init];
+ window_ = OCMClassMock([UIWindow class]);
+ }
+
+ protected:
+ RootCoordinator* coordinator_;
+ ApplicationState* state_;
+ id window_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RootCoordinatorApplicationStepTest);
+};
+
+// Tests that the coordinator can run if the window is key and application is
+// foregrounded.
+TEST_F(RootCoordinatorApplicationStepTest, TestRunsInKeyWindow) {
+ state_.phase = APPLICATION_FOREGROUNDED;
+ state_.window = window_;
+ OCMStub([window_ isKeyWindow]).andReturn(YES);
+ EXPECT_TRUE([coordinator_ canRunInState:state_]);
+}
+
+// Tests that the coordinator cannot run if the window is not key.
+TEST_F(RootCoordinatorApplicationStepTest, TestCannotRunWithoutKeyWindow) {
+ state_.phase = APPLICATION_FOREGROUNDED;
+ state_.window = window_;
+ OCMStub([window_ isKeyWindow]).andReturn(NO);
+ EXPECT_FALSE([coordinator_ canRunInState:state_]);
+}
+
+// Tests that the coordinator cannot run if application is not foregrounded.
+TEST_F(RootCoordinatorApplicationStepTest, TestCannotRunIfNotForegrounded) {
+ state_.phase = APPLICATION_COLD;
+ state_.window = window_;
+ OCMStub([window_ isKeyWindow]).andReturn(YES);
+ EXPECT_FALSE([coordinator_ canRunInState:state_]);
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698