This repository was archived by the owner on Sep 14, 2023. It is now read-only.
forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFWFUIViewHostApiTests.m
49 lines (36 loc) · 1.67 KB
/
FWFUIViewHostApiTests.m
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
42
43
44
45
46
47
48
49
// 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.
@import Flutter;
@import XCTest;
@import webview_flutter_wkwebview;
#import <OCMock/OCMock.h>
@interface FWFUIViewHostApiTests : XCTestCase
@end
@implementation FWFUIViewHostApiTests
- (void)testSetBackgroundColor {
UIView *mockUIView = OCMClassMock([UIView class]);
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0];
FWFUIViewHostApiImpl *hostAPI =
[[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager];
FlutterError *error;
[hostAPI setBackgroundColorForViewWithIdentifier:@0 toValue:@123 error:&error];
OCMVerify([mockUIView setBackgroundColor:[UIColor colorWithRed:(123 >> 16 & 0xff) / 255.0
green:(123 >> 8 & 0xff) / 255.0
blue:(123 & 0xff) / 255.0
alpha:(123 >> 24 & 0xff) / 255.0]]);
XCTAssertNil(error);
}
- (void)testSetOpaque {
UIView *mockUIView = OCMClassMock([UIView class]);
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
[instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0];
FWFUIViewHostApiImpl *hostAPI =
[[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager];
FlutterError *error;
[hostAPI setOpaqueForViewWithIdentifier:@0 isOpaque:@YES error:&error];
OCMVerify([mockUIView setOpaque:YES]);
XCTAssertNil(error);
}
@end