This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Expand file tree
/
Copy pathFlutterViewEngineProviderTest.mm
More file actions
41 lines (33 loc) · 1.7 KB
/
FlutterViewEngineProviderTest.mm
File metadata and controls
41 lines (33 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2013 The Flutter 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 <Carbon/Carbon.h>
#import <Foundation/Foundation.h>
#import <OCMock/OCMock.h>
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.h"
#import "flutter/testing/testing.h"
#include "third_party/googletest/googletest/include/gtest/gtest.h"
#import "flutter/testing/testing.h"
#include "third_party/googletest/googletest/include/gtest/gtest.h"
namespace flutter::testing {
TEST(FlutterViewEngineProviderUnittests, GetViewReturnsTheCorrectView) {
FlutterViewEngineProvider* viewProvider;
id mockEngine = OCMClassMock([FlutterEngine class]);
__block id mockFlutterViewController;
OCMStub([mockEngine viewController]).andDo(^(NSInvocation* invocation) {
if (mockFlutterViewController != nil) {
[invocation setReturnValue:&mockFlutterViewController];
}
});
viewProvider = [[FlutterViewEngineProvider alloc] initWithEngine:mockEngine];
// When the view controller is not set, the returned view is nil.
EXPECT_EQ([viewProvider getView:0], nil);
// When the view controller is set, the returned view is the controller's view.
mockFlutterViewController = OCMStrictClassMock([FlutterViewController class]);
id mockView = OCMStrictClassMock([FlutterView class]);
OCMStub([mockFlutterViewController flutterView]).andReturn(mockView);
EXPECT_EQ([viewProvider getView:0], mockView);
}
} // namespace flutter::testing