Add integration test of textures (#13122)
diff --git a/dev/devicelab/bin/tasks/external_ui_integration_test.dart b/dev/devicelab/bin/tasks/external_ui_integration_test.dart new file mode 100644 index 0000000..0866f7a --- /dev/null +++ b/dev/devicelab/bin/tasks/external_ui_integration_test.dart
@@ -0,0 +1,14 @@ +// 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 'dart:async'; + +import 'package:flutter_devicelab/framework/adb.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/tasks/integration_tests.dart'; + +Future<Null> main() async { + deviceOperatingSystem = DeviceOperatingSystem.android; + await task(createExternalUiIntegrationTest()); +}
diff --git a/dev/devicelab/bin/tasks/external_ui_integration_test_ios.dart b/dev/devicelab/bin/tasks/external_ui_integration_test_ios.dart new file mode 100644 index 0000000..2da7c73 --- /dev/null +++ b/dev/devicelab/bin/tasks/external_ui_integration_test_ios.dart
@@ -0,0 +1,14 @@ +// 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 'dart:async'; + +import 'package:flutter_devicelab/framework/adb.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/tasks/integration_tests.dart'; + +Future<Null> main() async { + deviceOperatingSystem = DeviceOperatingSystem.ios; + await task(createExternalUiIntegrationTest()); +}
diff --git a/dev/devicelab/lib/tasks/integration_tests.dart b/dev/devicelab/lib/tasks/integration_tests.dart index f612326..af4334a 100644 --- a/dev/devicelab/lib/tasks/integration_tests.dart +++ b/dev/devicelab/lib/tasks/integration_tests.dart
@@ -31,6 +31,13 @@ ); } +TaskFunction createExternalUiIntegrationTest() { + return new DriverTest( + '${flutterDirectory.path}/dev/integration_tests/external_ui', + 'lib/main.dart', + ); +} + TaskFunction createPlatformChannelSampleTest() { return new DriverTest( '${flutterDirectory.path}/examples/platform_channel',
diff --git a/dev/devicelab/manifest.yaml b/dev/devicelab/manifest.yaml index 2ae69aa..28970aa 100644 --- a/dev/devicelab/manifest.yaml +++ b/dev/devicelab/manifest.yaml
@@ -71,6 +71,13 @@ stage: devicelab required_agent_capabilities: ["has-android-device"] + external_ui_integration_test: + description: > + Checks that external UIs work on Android. + stage: devicelab + required_agent_capabilities: ["has-android-device"] + flaky: true + platform_interaction_test: description: > Checks platform interaction on Android. @@ -185,6 +192,13 @@ stage: devicelab_ios required_agent_capabilities: ["has-ios-device"] + external_ui_integration_test_ios: + description: > + Checks that external UIs work on iOS. + stage: devicelab + required_agent_capabilities: ["has-ios-device"] + flaky: true + channels_integration_test_ios: description: > Checks that platform channels work on iOS.
diff --git a/dev/integration_tests/external_ui/.gitignore b/dev/integration_tests/external_ui/.gitignore new file mode 100644 index 0000000..eb15c3d --- /dev/null +++ b/dev/integration_tests/external_ui/.gitignore
@@ -0,0 +1,10 @@ +.DS_Store +.atom/ +.idea +.packages +.pub/ +build/ +ios/.generated/ +packages +pubspec.lock +.flutter-plugins
diff --git a/dev/integration_tests/external_ui/README.md b/dev/integration_tests/external_ui/README.md new file mode 100644 index 0000000..a51e946 --- /dev/null +++ b/dev/integration_tests/external_ui/README.md
@@ -0,0 +1,3 @@ +# external_ui + +A Flutter project for testing external texture rendering.
diff --git a/dev/integration_tests/external_ui/android/.gitignore b/dev/integration_tests/external_ui/android/.gitignore new file mode 100644 index 0000000..1658458 --- /dev/null +++ b/dev/integration_tests/external_ui/android/.gitignore
@@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +GeneratedPluginRegistrant.java
diff --git a/dev/integration_tests/external_ui/android/app/build.gradle b/dev/integration_tests/external_ui/android/app/build.gradle new file mode 100644 index 0000000..3fce731 --- /dev/null +++ b/dev/integration_tests/external_ui/android/app/build.gradle
@@ -0,0 +1,49 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withInputStream { stream -> + localProperties.load(stream) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 25 + buildToolsVersion '25.0.3' + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + applicationId "com.yourcompany.externalui" + minSdkVersion 16 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + androidTestCompile 'com.android.support:support-annotations:25.4.0' + androidTestCompile 'com.android.support.test:runner:0.5' + androidTestCompile 'com.android.support.test:rules:0.5' +}
diff --git a/dev/integration_tests/external_ui/android/app/src/main/AndroidManifest.xml b/dev/integration_tests/external_ui/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..dc488a9 --- /dev/null +++ b/dev/integration_tests/external_ui/android/app/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.yourcompany.externalui"> + + <uses-permission android:name="android.permission.INTERNET"/> + + <application + android:name="io.flutter.app.FlutterApplication" + android:label="external_ui"> + <activity + android:name=".MainActivity" + android:launchMode="singleTop" + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale" + android:hardwareAccelerated="true" + android:windowSoftInputMode="adjustResize"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + </application> +</manifest>
diff --git a/dev/integration_tests/external_ui/android/app/src/main/java/com/yourcompany/externalui/MainActivity.java b/dev/integration_tests/external_ui/android/app/src/main/java/com/yourcompany/externalui/MainActivity.java new file mode 100644 index 0000000..e50f759 --- /dev/null +++ b/dev/integration_tests/external_ui/android/app/src/main/java/com/yourcompany/externalui/MainActivity.java
@@ -0,0 +1,141 @@ +// 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. + +package com.yourcompany.externalui; + +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.SurfaceTexture; +import android.os.Build; +import android.os.Bundle; +import android.view.Surface; +import android.view.SurfaceHolder; + +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.atomic.AtomicInteger; + +import io.flutter.app.FlutterActivity; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.MethodChannel.MethodCallHandler; +import io.flutter.plugin.common.MethodChannel.Result; +import io.flutter.view.TextureRegistry; +import io.flutter.view.TextureRegistry.SurfaceTextureEntry; + +public class MainActivity extends FlutterActivity { + private Surface surface; + private SurfaceTexture texture; + private Timer producerTimer; + private Timer consumerTimer; + private long startTime; + private long endTime; + private AtomicInteger framesProduced = new AtomicInteger(0); + private AtomicInteger framesConsumed = new AtomicInteger(0); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final MethodChannel channel = new MethodChannel(getFlutterView(), "texture"); + channel.setMethodCallHandler(new MethodCallHandler() { + @Override + public void onMethodCall(MethodCall methodCall, Result result) { + switch (methodCall.method) { + case "start": + framesProduced.set(0); + framesConsumed.set(0); + final int fps = methodCall.arguments(); + final FrameRenderer renderer = new FrameRenderer(surface); + producerTimer = new Timer(); + producerTimer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + renderer.drawFrame(); + framesProduced.incrementAndGet(); + } + }, 0, 1000 / fps); + consumerTimer = new Timer(); + consumerTimer.scheduleAtFixedRate(new TimerTask() { + private long lastTimestamp = -1L; + + @Override + public void run() { + final long timestamp = texture.getTimestamp(); + // The texture's timestamp is updated on consumption. + // We detect the change by asking very frequently. + if (timestamp != lastTimestamp) { + lastTimestamp = timestamp; + framesConsumed.incrementAndGet(); + } + } + }, 0, 1); + startTime = System.currentTimeMillis(); + result.success(null); + break; + case "stop": + producerTimer.cancel(); + consumerTimer.cancel(); + endTime = System.currentTimeMillis(); + result.success(null); + break; + case "getProducedFrameRate": + result.success(framesProduced.get() * 1000 / (double) (endTime - startTime)); + break; + case "getConsumedFrameRate": + result.success(framesConsumed.get() * 1000 / (double) (endTime - startTime)); + break; + default: result.notImplemented(); + } + } + }); + + getFlutterView().getHolder().addCallback(new SurfaceHolder.Callback() { + @Override + public void surfaceCreated(SurfaceHolder holder) { + final SurfaceTextureEntry textureEntry = getFlutterView().createSurfaceTexture(); + texture = textureEntry.surfaceTexture(); + texture.setDefaultBufferSize(300, 200); + surface = new Surface(texture); + } + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + } + }); + } + + @Override + protected void onDestroy() { + if (surface != null) { + surface.release(); + } + super.onDestroy(); + } +} + +class FrameRenderer { + private final Surface surface; + private final Paint paint; + private int frameCount = 0; + + FrameRenderer(Surface surface) { + this.surface = surface; + this.paint = new Paint(); + paint.setColor(0xffff0000); + paint.setTextSize(48.0f); + paint.setAntiAlias(true); + } + + void drawFrame() { + final Canvas canvas = surface.lockCanvas(null); + canvas.drawColor(0xff000000); + canvas.drawText(String.valueOf(++frameCount), 20, 120, paint); + surface.unlockCanvasAndPost(canvas); + } +}
diff --git a/dev/integration_tests/external_ui/android/build.gradle b/dev/integration_tests/external_ui/android/build.gradle new file mode 100644 index 0000000..77cbd09 --- /dev/null +++ b/dev/integration_tests/external_ui/android/build.gradle
@@ -0,0 +1,31 @@ +buildscript { + repositories { + jcenter() + maven { + url "https://maven.google.com" + } + } + + dependencies { + classpath 'com.android.tools.build:gradle:2.3.3' + } +} + +allprojects { + repositories { + jcenter() + maven { + url "https://maven.google.com" + } + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +}
diff --git a/dev/integration_tests/external_ui/android/gradle.properties b/dev/integration_tests/external_ui/android/gradle.properties new file mode 100644 index 0000000..8bd86f6 --- /dev/null +++ b/dev/integration_tests/external_ui/android/gradle.properties
@@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx1536M
diff --git a/dev/integration_tests/external_ui/android/gradle/wrapper/gradle-wrapper.properties b/dev/integration_tests/external_ui/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..45e7f14 --- /dev/null +++ b/dev/integration_tests/external_ui/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
diff --git a/dev/integration_tests/external_ui/android/settings.gradle b/dev/integration_tests/external_ui/android/settings.gradle new file mode 100644 index 0000000..115da6c --- /dev/null +++ b/dev/integration_tests/external_ui/android/settings.gradle
@@ -0,0 +1,15 @@ +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withInputStream { stream -> plugins.load(stream) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +}
diff --git a/dev/integration_tests/external_ui/ios/.gitignore b/dev/integration_tests/external_ui/ios/.gitignore new file mode 100644 index 0000000..38864ee --- /dev/null +++ b/dev/integration_tests/external_ui/ios/.gitignore
@@ -0,0 +1,41 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/app.flx +/Flutter/app.zip +/Flutter/App.framework +/Flutter/Flutter.framework +/Flutter/Generated.xcconfig +/ServiceDefinitions.json + +Pods/
diff --git a/dev/integration_tests/external_ui/ios/Flutter/AppFrameworkInfo.plist b/dev/integration_tests/external_ui/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..6c2de80 --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Flutter/AppFrameworkInfo.plist
@@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>App</string> + <key>CFBundleIdentifier</key> + <string>io.flutter.flutter.app</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>App</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>UIRequiredDeviceCapabilities</key> + <array> + <string>arm64</string> + </array> + <key>MinimumOSVersion</key> + <string>8.0</string> +</dict> +</plist>
diff --git a/dev/integration_tests/external_ui/ios/Flutter/Debug.xcconfig b/dev/integration_tests/external_ui/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Flutter/Debug.xcconfig
@@ -0,0 +1 @@ +#include "Generated.xcconfig"
diff --git a/dev/integration_tests/external_ui/ios/Flutter/Release.xcconfig b/dev/integration_tests/external_ui/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Flutter/Release.xcconfig
@@ -0,0 +1 @@ +#include "Generated.xcconfig"
diff --git a/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3099a2e --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.pbxproj
@@ -0,0 +1,413 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; + 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; }; + 9740EEBB1CF902C7004384FC /* app.flx in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB71CF902C7004384FC /* app.flx */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; + 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; }; + 9740EEB71CF902C7004384FC /* app.flx */ = {isa = PBXFileReference; lastKnownFileType = file; name = app.flx; path = Flutter/app.flx; sourceTree = "<group>"; }; + 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 9740EEB71CF902C7004384FC /* app.flx */, + 3B80C3931E831B6300D905FE /* App.framework */, + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEBA1CF902C7004384FC /* Flutter.framework */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = "<group>"; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + ); + sourceTree = "<group>"; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = "<group>"; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + ); + path = Runner; + sourceTree = "<group>"; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = "The Chromium Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9740EEBB1CF902C7004384FC /* app.flx in Resources */, + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = "<group>"; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = "<group>"; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ARCHS = arm64; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.externalUi; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ARCHS = arm64; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.externalUi; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +}
diff --git a/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "group:Runner.xcodeproj"> + </FileRef> +</Workspace>
diff --git a/dev/integration_tests/external_ui/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/dev/integration_tests/external_ui/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..1c95807 --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0830" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "97C146ED1CF9000F007C117D" + BuildableName = "Runner.app" + BlueprintName = "Runner" + ReferencedContainer = "container:Runner.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + </Testables> + <MacroExpansion> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "97C146ED1CF9000F007C117D" + BuildableName = "Runner.app" + BlueprintName = "Runner" + ReferencedContainer = "container:Runner.xcodeproj"> + </BuildableReference> + </MacroExpansion> + <AdditionalOptions> + </AdditionalOptions> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <BuildableProductRunnable + runnableDebuggingMode = "0"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "97C146ED1CF9000F007C117D" + BuildableName = "Runner.app" + BlueprintName = "Runner" + ReferencedContainer = "container:Runner.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + <BuildableProductRunnable + runnableDebuggingMode = "0"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "97C146ED1CF9000F007C117D" + BuildableName = "Runner.app" + BlueprintName = "Runner" + ReferencedContainer = "container:Runner.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme>
diff --git a/dev/integration_tests/external_ui/ios/Runner.xcworkspace/contents.xcworkspacedata b/dev/integration_tests/external_ui/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "group:Runner.xcodeproj"> + </FileRef> +</Workspace>
diff --git a/dev/integration_tests/external_ui/ios/Runner/AppDelegate.h b/dev/integration_tests/external_ui/ios/Runner/AppDelegate.h new file mode 100644 index 0000000..586d534 --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner/AppDelegate.h
@@ -0,0 +1,10 @@ +// 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 <UIKit/UIKit.h> +#import <Flutter/Flutter.h> + +@interface AppDelegate : FlutterAppDelegate<FlutterTexture> + +@end
diff --git a/dev/integration_tests/external_ui/ios/Runner/AppDelegate.m b/dev/integration_tests/external_ui/ios/Runner/AppDelegate.m new file mode 100644 index 0000000..83d3f88 --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner/AppDelegate.m
@@ -0,0 +1,76 @@ +// 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 "AppDelegate.h" + +@interface AppDelegate () + @property (atomic) uint64_t textureId; + @property (atomic) int framesProduced; + @property (atomic) int framesConsumed; + @property (atomic) int lastFrameConsumed; + @property (atomic) double startTime; + @property (atomic) double endTime; + @property (atomic) double frameRate; + @property (atomic) double frameStartTime; + @property (atomic) NSTimer* timer; + + - (void)tick:(NSTimer*)timer; +@end + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + FlutterViewController* flutterController = + (FlutterViewController*)self.window.rootViewController; + FlutterMethodChannel* channel = + [FlutterMethodChannel methodChannelWithName:@"texture" + binaryMessenger:flutterController]; + [channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { + if ([@"start" isEqualToString:call.method]) { + _framesProduced = 0; + _framesConsumed = 0; + _frameRate = 1.0 / [(NSNumber*) call.arguments intValue]; + _timer = [NSTimer scheduledTimerWithTimeInterval:_frameRate + target:self + selector:@selector(tick:) + userInfo:nil + repeats:YES]; + _startTime = [[NSDate date] timeIntervalSince1970]; + result(nil); + } else if ([@"stop" isEqualToString:call.method]) { + [_timer invalidate]; + _endTime = [[NSDate date] timeIntervalSince1970]; + result(nil); + } else if ([@"getProducedFrameRate" isEqualToString:call.method]) { + result(@(_framesProduced / (_endTime - _startTime))); + } else if ([@"getConsumedFrameRate" isEqualToString:call.method]) { + result(@(_framesConsumed / (_endTime - _startTime))); + } else { + result(FlutterMethodNotImplemented); + } + }]; + _textureId = [flutterController registerTexture:self]; + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +- (void)tick:(NSTimer*)timer { + FlutterViewController* flutterController = + (FlutterViewController*)self.window.rootViewController; + [flutterController textureFrameAvailable:_textureId]; + _frameStartTime = [[NSDate date] timeIntervalSince1970]; + // We just pretend to be producing a frame. + _framesProduced++; +} + +- (CVPixelBufferRef)copyPixelBuffer { + double now = [[NSDate date] timeIntervalSince1970]; + if (now < _frameStartTime + || _frameStartTime + _frameRate < now + || _framesProduced == _lastFrameConsumed) return nil; + _framesConsumed++; + _lastFrameConsumed = _framesProduced; + // We just pretend to be handing over the produced frame to the consumer. + return nil; +} +@end
diff --git a/dev/integration_tests/external_ui/ios/Runner/Base.lproj/LaunchScreen.storyboard b/dev/integration_tests/external_ui/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner/Base.lproj/LaunchScreen.storyboard
@@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> + <dependencies> + <deployment identifier="iOS"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> + </dependencies> + <scenes> + <!--View Controller--> + <scene sceneID="EHf-IW-A2E"> + <objects> + <viewController id="01J-lp-oVM" sceneMemberID="viewController"> + <layoutGuides> + <viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/> + <viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/> + </layoutGuides> + <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"> + </imageView> + </subviews> + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + <constraints> + <constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/> + <constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/> + </constraints> + </view> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="53" y="375"/> + </scene> + </scenes> + <resources> + <image name="LaunchImage" width="168" height="185"/> + </resources> +</document>
diff --git a/dev/integration_tests/external_ui/ios/Runner/Base.lproj/Main.storyboard b/dev/integration_tests/external_ui/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner/Base.lproj/Main.storyboard
@@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> + <dependencies> + <deployment identifier="iOS"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> + </dependencies> + <scenes> + <!--Flutter View Controller--> + <scene sceneID="tne-QT-ifu"> + <objects> + <viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController"> + <layoutGuides> + <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> + <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> + </layoutGuides> + <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> + <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> + </view> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> + </objects> + </scene> + </scenes> +</document>
diff --git a/dev/integration_tests/external_ui/ios/Runner/Info.plist b/dev/integration_tests/external_ui/ios/Runner/Info.plist new file mode 100644 index 0000000..2e5b6ec --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner/Info.plist
@@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>external_ui</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSRequiresIPhoneOS</key> + <true/> + <key>UILaunchStoryboardName</key> + <string>LaunchScreen</string> + <key>UIMainStoryboardFile</key> + <string>Main</string> + <key>UIRequiredDeviceCapabilities</key> + <array> + <string>arm64</string> + </array> + <key>UISupportedInterfaceOrientations</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> + </array> + <key>UISupportedInterfaceOrientations~ipad</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationPortraitUpsideDown</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> + </array> + <key>UIViewControllerBasedStatusBarAppearance</key> + <false/> +</dict> +</plist>
diff --git a/dev/integration_tests/external_ui/ios/Runner/main.m b/dev/integration_tests/external_ui/ios/Runner/main.m new file mode 100644 index 0000000..3ffadad --- /dev/null +++ b/dev/integration_tests/external_ui/ios/Runner/main.m
@@ -0,0 +1,13 @@ +// 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 <UIKit/UIKit.h> +#import <Flutter/Flutter.h> +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}
diff --git a/dev/integration_tests/external_ui/lib/main.dart b/dev/integration_tests/external_ui/lib/main.dart new file mode 100644 index 0000000..496a23b --- /dev/null +++ b/dev/integration_tests/external_ui/lib/main.dart
@@ -0,0 +1,148 @@ +// 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 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_driver/driver_extension.dart'; + +void main() { + enableFlutterDriverExtension(); + runApp(new MyApp()); +} + +class MyApp extends StatefulWidget { + @override + State createState() => new MyAppState(); +} + +const MethodChannel channel = const MethodChannel('texture'); + +enum FrameState { initial, slow, afterSlow, fast, afterFast } + +class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { + int _widgetBuilds = 0; + FrameState _state; + String _summary = ''; + IconData _icon; + double _flutterFrameRate; + + Future<Null> _summarizeStats() async { + final double framesProduced = await channel.invokeMethod('getProducedFrameRate'); + final double framesConsumed = await channel.invokeMethod('getConsumedFrameRate'); + _summary = ''' +Produced: ${framesProduced.toStringAsFixed(1)}fps +Consumed: ${framesConsumed.toStringAsFixed(1)}fps +Widget builds: $_widgetBuilds'''; + } + + Future<Null> _nextState() async { + switch (_state) { + case FrameState.initial: + _widgetBuilds = 0; + _summary = 'Producing texture frames at .5x speed...'; + _state = FrameState.slow; + _icon = Icons.stop; + channel.invokeMethod('start', _flutterFrameRate ~/ 2); + break; + case FrameState.slow: + await channel.invokeMethod('stop'); + await _summarizeStats(); + _icon = Icons.fast_forward; + _state = FrameState.afterSlow; + break; + case FrameState.afterSlow: + _widgetBuilds = 0; + _summary = 'Producing texture frames at 2x speed...'; + _state = FrameState.fast; + _icon = Icons.stop; + channel.invokeMethod('start', (_flutterFrameRate * 2).toInt()); + break; + case FrameState.fast: + await channel.invokeMethod('stop'); + await _summarizeStats(); + _state = FrameState.afterFast; + _icon = Icons.replay; + break; + case FrameState.afterFast: + _summary = 'Press play to start again'; + _state = FrameState.initial; + _icon = Icons.play_arrow; + break; + } + setState(() {}); + } + + @override + void initState() { + super.initState(); + _calibrate(); + } + + /// Measures Flutter's frame rate. + Future<Null> _calibrate() async { + await new Future<Null>.delayed(const Duration(milliseconds: 200)); + DateTime startTime; + int tickCount = 0; + Ticker ticker; + ticker = createTicker((Duration _) { + tickCount++; + if (tickCount == 120) { + final Duration elapsed = new DateTime.now().difference(startTime); + ticker.stop(); + ticker.dispose(); + setState(() { + _flutterFrameRate = tickCount * 1000 / elapsed.inMilliseconds; + _summary = 'Flutter frame rate is ${_flutterFrameRate.toStringAsFixed(1)}fps.\nPress play to produce texture frames.'; + _icon = Icons.play_arrow; + _state = FrameState.initial; + }); + } + }); + ticker.start(); + startTime = new DateTime.now(); + setState(() { + _summary = 'Calibrating...'; + _icon = null; + }); + } + + @override + Widget build(BuildContext context) { + _widgetBuilds++; + return new MaterialApp( + home: new Scaffold( + body: new Center( + child: new Column( + mainAxisAlignment: MainAxisAlignment.center, + children: <Widget>[ + new Container( + width: 300.0, + height: 200.0, + child: const Texture(textureId: 0), + ), + new Container( + width: 300.0, + height: 60.0, + color: Colors.grey, + child: new Center( + child: new Text( + _summary, + key: const ValueKey<String>('summary'), + ), + ), + ), + ], + ), + ), + floatingActionButton: (_icon == null ? null : new FloatingActionButton( + key: const ValueKey<String>('fab'), + child: new Icon(_icon), + onPressed: _nextState, + )), + ), + ); + } +}
diff --git a/dev/integration_tests/external_ui/pubspec.yaml b/dev/integration_tests/external_ui/pubspec.yaml new file mode 100644 index 0000000..dd37472 --- /dev/null +++ b/dev/integration_tests/external_ui/pubspec.yaml
@@ -0,0 +1,11 @@ +name: external_ui +description: A test of Flutter integrating external UIs. + +dependencies: + flutter: + sdk: flutter + flutter_driver: + sdk: flutter + +flutter: + uses-material-design: true
diff --git a/dev/integration_tests/external_ui/test_driver/main_test.dart b/dev/integration_tests/external_ui/test_driver/main_test.dart new file mode 100644 index 0000000..fd762fc --- /dev/null +++ b/dev/integration_tests/external_ui/test_driver/main_test.dart
@@ -0,0 +1,65 @@ +// 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 'dart:async'; +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:test/test.dart'; + +final RegExp calibrationRegExp = new RegExp('Flutter frame rate is (.*)fps'); +final RegExp statsRegExp = new RegExp('Produced: (.*)fps\nConsumed: (.*)fps\nWidget builds: (.*)'); +const Duration samplingTime = const Duration(seconds: 3); + +Future<Null> main() async { + group('texture suite', () { + FlutterDriver driver; + + setUpAll(() async { + driver = await FlutterDriver.connect(); + // TODO(mravn): the following pause appears necessary on iOS to avoid + // inflating elements too early (when there is no size). + await new Future<Null>.delayed(const Duration(seconds: 1)); + }); + + test('texture rendering', () async { + final SerializableFinder fab = find.byValueKey('fab'); + final SerializableFinder summary = find.byValueKey('summary'); + + // Wait for calibration to complete and fab to appear. + await driver.waitFor(fab, timeout: const Duration(seconds: 10)); + + final String calibrationResult = await driver.getText(summary); + final Match matchCalibration = calibrationRegExp.matchAsPrefix(calibrationResult); + expect(matchCalibration, isNotNull); + final double flutterFrameRate = double.parse(matchCalibration.group(1)); + + // Texture frame stats at 0.5x Flutter frame rate + await driver.tap(fab); + await new Future<Null>.delayed(samplingTime); + await driver.tap(fab); + + final String statsSlow = await driver.getText(summary); + final Match matchSlow = statsRegExp.matchAsPrefix(statsSlow); + expect(matchSlow, isNotNull); + expect(double.parse(matchSlow.group(1)), closeTo(flutterFrameRate / 2.0, 5.0)); + expect(double.parse(matchSlow.group(2)), closeTo(flutterFrameRate / 2.0, 5.0)); + expect(int.parse(matchSlow.group(3)), 1); + + // Texture frame stats at 2.0x Flutter frame rate + await driver.tap(fab); + await new Future<Null>.delayed(samplingTime); + await driver.tap(fab); + + final String statsFast = await driver.getText(summary); + final Match matchFast = statsRegExp.matchAsPrefix(statsFast); + expect(matchFast, isNotNull); + expect(double.parse(matchFast.group(1)), closeTo(flutterFrameRate * 2.0, 10.0)); + expect(double.parse(matchFast.group(2)), closeTo(flutterFrameRate, 10.0)); + expect(int.parse(matchFast.group(3)), 1); + }); + + tearDownAll(() async { + driver?.close(); + }); + }); +}