Skip to content

Commit 6c6ae06

Browse files
Add Windows to the platform_channels example (flutter#106754)
1 parent b38150f commit 6c6ae06

34 files changed

+1215
-4
lines changed

.ci.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3981,6 +3981,21 @@ targets:
39813981
- bin/**
39823982
- .ci.yaml
39833983

3984+
- name: Windows platform_channel_sample_test_windows
3985+
recipe: devicelab/devicelab_drone
3986+
presubmit: false
3987+
timeout: 60
3988+
properties:
3989+
dependencies: >-
3990+
[
3991+
{"dependency": "vs_build", "version": "version:vs2019"}
3992+
]
3993+
tags: >
3994+
["devicelab", "hostonly"]
3995+
task_name: platform_channel_sample_test_windows
3996+
scheduler: luci
3997+
bringup: true
3998+
39843999
- name: Windows plugin_dependencies_test
39854000
recipe: devicelab/devicelab_drone
39864001
timeout: 60

TESTOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
/dev/devicelab/bin/tasks/module_test.dart @zanderso @flutter/tool
200200
/dev/devicelab/bin/tasks/native_platform_view_ui_tests_ios.dart @hellohuanlin @flutter/ios
201201
/dev/devicelab/bin/tasks/native_ui_tests_macos.dart @cbracken @flutter/desktop
202+
/dev/devicelab/bin/tasks/platform_channel_sample_test_windows.dart @cbracken @flutter/desktop
202203
/dev/devicelab/bin/tasks/plugin_test.dart @stuartmorgan @flutter/plugin
203204
/dev/devicelab/bin/tasks/plugin_test_ios.dart @jmagman @flutter/ios
204205
/dev/devicelab/bin/tasks/technical_debt__cost.dart @HansMuller @flutter/framework

dev/bots/analyze.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ Future<void> verifyNoMissingLicense(String workingDirectory, { bool checkMinimum
544544
failed += await _verifyNoMissingLicenseForExtension(workingDirectory, 'java', overrideMinimumMatches ?? 39, _generateLicense('// '));
545545
failed += await _verifyNoMissingLicenseForExtension(workingDirectory, 'h', overrideMinimumMatches ?? 30, _generateLicense('// '));
546546
failed += await _verifyNoMissingLicenseForExtension(workingDirectory, 'm', overrideMinimumMatches ?? 30, _generateLicense('// '));
547+
failed += await _verifyNoMissingLicenseForExtension(workingDirectory, 'cpp', overrideMinimumMatches ?? 0, _generateLicense('// '));
547548
failed += await _verifyNoMissingLicenseForExtension(workingDirectory, 'swift', overrideMinimumMatches ?? 10, _generateLicense('// '));
548549
failed += await _verifyNoMissingLicenseForExtension(workingDirectory, 'gradle', overrideMinimumMatches ?? 80, _generateLicense('// '));
549550
failed += await _verifyNoMissingLicenseForExtension(workingDirectory, 'gn', overrideMinimumMatches ?? 0, _generateLicense('# '));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2014 The Flutter 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+
import 'package:flutter_devicelab/framework/framework.dart';
6+
import 'package:flutter_devicelab/tasks/integration_tests.dart';
7+
8+
Future<void> main() async {
9+
await task(createPlatformChannelSampleTest(deviceIdOverride: 'windows'));
10+
}

dev/devicelab/lib/tasks/integration_tests.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ TaskFunction createExternalUiIntegrationTest() {
4444
);
4545
}
4646

47-
TaskFunction createPlatformChannelSampleTest() {
47+
TaskFunction createPlatformChannelSampleTest({String? deviceIdOverride}) {
4848
return DriverTest(
4949
'${flutterDirectory.path}/examples/platform_channel',
5050
'test_driver/button_tap.dart',
51+
deviceIdOverride: deviceIdOverride,
5152
);
5253
}
5354

@@ -146,18 +147,25 @@ class DriverTest {
146147
this.testDirectory,
147148
this.testTarget, {
148149
this.extraOptions = const <String>[],
150+
this.deviceIdOverride,
149151
}
150152
);
151153

152154
final String testDirectory;
153155
final String testTarget;
154156
final List<String> extraOptions;
157+
final String? deviceIdOverride;
155158

156159
Future<TaskResult> call() {
157160
return inDirectory<TaskResult>(testDirectory, () async {
158-
final Device device = await devices.workingDevice;
159-
await device.unlock();
160-
final String deviceId = device.deviceId;
161+
String deviceId;
162+
if (deviceIdOverride != null) {
163+
deviceId = deviceIdOverride!;
164+
} else {
165+
final Device device = await devices.workingDevice;
166+
await device.unlock();
167+
deviceId = device.deviceId;
168+
}
161169
await flutter('packages', options: <String>['get']);
162170

163171
final List<String> options = <String>[

dev/integration_tests/flutter_gallery/windows/runner/flutter_window.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include "flutter_window.h"
26

37
#include <optional>

dev/integration_tests/flutter_gallery/windows/runner/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include <flutter/dart_project.h>
26
#include <flutter/flutter_view_controller.h>
37
#include <windows.h>

dev/integration_tests/flutter_gallery/windows/runner/utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include "utils.h"
26

37
#include <flutter_windows.h>

dev/integration_tests/flutter_gallery/windows/runner/win32_window.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include "win32_window.h"
26

37
#include <flutter_windows.h>

dev/manual_tests/windows/runner/utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include "utils.h"
26

37
#include <flutter_windows.h>

dev/manual_tests/windows/runner/win32_window.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include "win32_window.h"
26

37
#include <flutter_windows.h>

examples/api/windows/runner/flutter_window.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include "flutter_window.h"
26

37
#include <optional>

examples/api/windows/runner/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include <flutter/dart_project.h>
26
#include <flutter/flutter_view_controller.h>
37
#include <windows.h>

examples/api/windows/runner/utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include "utils.h"
26

37
#include <flutter_windows.h>

examples/api/windows/runner/win32_window.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2014 The Flutter 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+
15
#include "win32_window.h"
26

37
#include <flutter_windows.h>

examples/platform_channel/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ and build/run the project as usual.
1515
You can use the commands `flutter build` and `flutter run` from the app's root
1616
directory to build/run the app or to build with Android Studio, open the
1717
`android` folder in Android Studio and build the project as usual.
18+
19+
## Windows
20+
You can use the commands `flutter build` and `flutter run` from the app's root
21+
directory to build/run the app or you can build once then open
22+
`build\windows\platform_channel.sln` in Visual Studio to build and run.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BasedOnStyle: Google
2+
---
3+
Language: Cpp
4+
DerivePointerAlignment: false
5+
PointerAlignment: Left
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
flutter/ephemeral/
2+
3+
# Visual Studio user-specific files.
4+
*.suo
5+
*.user
6+
*.userosscache
7+
*.sln.docstates
8+
9+
# Visual Studio build-related files.
10+
x64/
11+
x86/
12+
13+
# Visual Studio cache files
14+
# files ending in .cache can be ignored
15+
*.[Cc]ache
16+
# but keep track of directories ending in .cache
17+
!*.[Cc]ache/
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Project-level configuration.
2+
cmake_minimum_required(VERSION 3.14)
3+
project(platform_channel LANGUAGES CXX)
4+
5+
# The name of the executable created for the application. Change this to change
6+
# the on-disk name of your application.
7+
set(BINARY_NAME "platform_channel")
8+
9+
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10+
# versions of CMake.
11+
cmake_policy(SET CMP0063 NEW)
12+
13+
# Define build configuration option.
14+
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15+
if(IS_MULTICONFIG)
16+
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17+
CACHE STRING "" FORCE)
18+
else()
19+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20+
set(CMAKE_BUILD_TYPE "Debug" CACHE
21+
STRING "Flutter build mode" FORCE)
22+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23+
"Debug" "Profile" "Release")
24+
endif()
25+
endif()
26+
# Define settings for the Profile build mode.
27+
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28+
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29+
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30+
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31+
32+
# Use Unicode for all projects.
33+
add_definitions(-DUNICODE -D_UNICODE)
34+
35+
# Compilation settings that should be applied to most targets.
36+
#
37+
# Be cautious about adding new options here, as plugins use this function by
38+
# default. In most cases, you should add new options to specific targets instead
39+
# of modifying this function.
40+
function(APPLY_STANDARD_SETTINGS TARGET)
41+
target_compile_features(${TARGET} PUBLIC cxx_std_17)
42+
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43+
target_compile_options(${TARGET} PRIVATE /EHsc)
44+
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45+
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
46+
endfunction()
47+
48+
# Flutter library and tool build rules.
49+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50+
add_subdirectory(${FLUTTER_MANAGED_DIR})
51+
52+
# Application build; see runner/CMakeLists.txt.
53+
add_subdirectory("runner")
54+
55+
# Generated plugin build rules, which manage building the plugins and adding
56+
# them to the application.
57+
include(flutter/generated_plugins.cmake)
58+
59+
60+
# === Installation ===
61+
# Support files are copied into place next to the executable, so that it can
62+
# run in place. This is done instead of making a separate bundle (as on Linux)
63+
# so that building and running from within Visual Studio will work.
64+
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
65+
# Make the "install" step default, as it's required to run.
66+
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
67+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
68+
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
69+
endif()
70+
71+
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
72+
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
73+
74+
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
75+
COMPONENT Runtime)
76+
77+
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
78+
COMPONENT Runtime)
79+
80+
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
81+
COMPONENT Runtime)
82+
83+
if(PLUGIN_BUNDLED_LIBRARIES)
84+
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
85+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
86+
COMPONENT Runtime)
87+
endif()
88+
89+
# Fully re-copy the assets directory on each build to avoid having stale files
90+
# from a previous install.
91+
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
92+
install(CODE "
93+
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
94+
" COMPONENT Runtime)
95+
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
96+
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
97+
98+
# Install the AOT library on non-Debug builds only.
99+
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
100+
CONFIGURATIONS Profile;Release
101+
COMPONENT Runtime)

0 commit comments

Comments
 (0)