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

Side by Side Diff: ios/chrome/app/multitasking_test_application_delegate.mm

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: Created 4 years 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 2016 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 "base/logging.h"
6 #import "ios/chrome/app/application_delegate/app_state.h"
7 #import "ios/chrome/app/chrome_overlay_window.h"
8 #import "ios/chrome/app/multitasking_test_application_delegate.h"
9
10 namespace {
11
12 // These command line switches enable slide over or split view test mode for
13 // multitasking tests. Only one of them should be enabled at any time.
14 NSString* const kEnableSlideOverTestMode = @"--enable-slide-over-test-mode";
15 NSString* const kEnableSplitViewTestMode = @"--enable-split-view-test-mode";
16
17 // Screen size of various iPad models in terms of logical points. All models
18 // have regular size except for 12.9 inch iPad Pro, which is slightly larger.
19 const CGSize kRegularIPadPortraitSize = CGSizeMake(768.0, 1024.0);
20 const CGSize kLargeIPadPortraitSize = CGSizeMake(1024.0, 1366.0);
21
22 // Width of the application window size while in portrait slide over mode or
23 // landscape half-screen split view mode. These values are obtained by running
24 // application in actual portrait slide over mode and landscape half-screen
25 // split view mode.
26 const CGFloat kWidthPortraitSlideOverOnRegularIPad = 320.0;
27 const CGFloat kWidthPortraitSlideOverOnLargeIPad = 375.0;
28 const CGFloat kWidthLandscapeSplitViewOnRegularIPad = 507.0;
29 const CGFloat kWidthLandscapeSplitViewOnLargeIPad = 678.0;
30
31 } // namespace
32
33 @implementation MultitaskingTestApplicationDelegate
34
35 - (BOOL)application:(UIApplication*)application
36 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
37 // Configure application window size for multitasking tests.
38 CGSize newWindowSize = [self windowSize];
39 self.window = [[[ChromeOverlayWindow alloc]
40 initWithFrame:CGRectMake(0, 0, newWindowSize.width, newWindowSize.height)]
41 autorelease];
42
43 BOOL inBackground =
44 [application applicationState] == UIApplicationStateBackground;
45 return [[self appState] requiresHandlingAfterLaunchWithOptions:launchOptions
46 stateBackground:inBackground];
47 }
48
49 // Returns true if test is running on 12.9 inch iPad Pro. Otherwise, it's
50 // running on regular iPad.
51 - (BOOL)isRunningOnLargeIPadPro {
52 CGSize size = [[UIScreen mainScreen] bounds].size;
53 return MAX(size.height, size.width) ==
54 MAX(kLargeIPadPortraitSize.width, kLargeIPadPortraitSize.height);
55 }
56
57 - (BOOL)IsRunningInSlideOverTestMode {
58 return [[[NSProcessInfo processInfo] arguments]
59 containsObject:kEnableSlideOverTestMode];
60 }
61
62 - (BOOL)IsRunningInSplitViewTestMode {
63 return [[[NSProcessInfo processInfo] arguments]
64 containsObject:kEnableSplitViewTestMode];
65 }
66
67 // Returns the size that will be used to configure the application window for
68 // multitasking tests. Both width and height are determined by the target name
69 // and on which iPad model it is running.
70 - (CGSize)windowSize {
71 CGSize size;
72 if ([self IsRunningInSlideOverTestMode]) {
73 if ([self isRunningOnLargeIPadPro]) {
74 size.width = kWidthPortraitSlideOverOnLargeIPad;
75 size.height = kLargeIPadPortraitSize.height;
76 } else {
77 size.width = kWidthPortraitSlideOverOnRegularIPad;
78 size.height = kRegularIPadPortraitSize.height;
79 }
80 } else if ([self IsRunningInSplitViewTestMode]) {
81 if ([self isRunningOnLargeIPadPro]) {
82 size.width = kWidthLandscapeSplitViewOnLargeIPad;
83 size.height = kLargeIPadPortraitSize.width;
84 } else {
85 size.width = kWidthLandscapeSplitViewOnRegularIPad;
86 size.height = kRegularIPadPortraitSize.width;
87 }
88 } else {
89 LOG(ERROR) << "Unsupported multitasking test mode.";
90 }
91 return size;
92 }
93
94 @end
OLDNEW
« no previous file with comments | « ios/chrome/app/multitasking_test_application_delegate.h ('k') | ios/chrome/app/safe_mode/safe_mode_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698