-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:flutter/packages into ima_android_b…
…asemanager
- Loading branch information
Showing
11 changed files
with
1,090 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/interactive_media_ads/example/ios/RunnerTests/CompanionAdSlotProxyApiTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// 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 GoogleInteractiveMediaAds | ||
import UIKit | ||
import XCTest | ||
|
||
@testable import interactive_media_ads | ||
|
||
class CompanionAdSlotProxyApiTests: XCTestCase { | ||
func testPigeonDefaultConstructor() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiIMACompanionAdSlot(registrar) | ||
|
||
let view = UIView() | ||
let instance = try! api.pigeonDelegate.pigeonDefaultConstructor(pigeonApi: api, view: view) | ||
XCTAssertEqual(instance.view, view) | ||
} | ||
|
||
func testSize() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiIMACompanionAdSlot(registrar) | ||
|
||
let view = UIView() | ||
let width = 0 | ||
let height = 1 | ||
let instance = try! api.pigeonDelegate.size( | ||
pigeonApi: api, view: view, width: Int64(width), height: Int64(height)) | ||
XCTAssertEqual(instance.view, view) | ||
XCTAssertEqual(instance.width, width) | ||
XCTAssertEqual(instance.height, height) | ||
} | ||
|
||
func testView() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiIMACompanionAdSlot(registrar) | ||
|
||
let instance = IMACompanionAdSlot(view: UIView()) | ||
let value = try? api.pigeonDelegate.view(pigeonApi: api, pigeonInstance: instance) | ||
|
||
XCTAssertEqual(value, instance.view) | ||
} | ||
|
||
func testSetDelegate() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiIMACompanionAdSlot(registrar) | ||
|
||
let instance = IMACompanionAdSlot(view: UIView()) | ||
let delegate = CompanionDelegateImpl( | ||
api: registrar.apiDelegate.pigeonApiIMACompanionDelegate(registrar)) | ||
try? api.pigeonDelegate.setDelegate( | ||
pigeonApi: api, pigeonInstance: instance, delegate: delegate) | ||
|
||
XCTAssertIdentical(instance.delegate, delegate) | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
packages/interactive_media_ads/example/ios/RunnerTests/CompanionDelegateProxyApiTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// 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 GoogleInteractiveMediaAds | ||
import UIKit | ||
import XCTest | ||
|
||
@testable import interactive_media_ads | ||
|
||
class CompanionDelegateProxyApiTests: XCTestCase { | ||
func testPigeonDefaultConstructor() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiIMACompanionDelegate(registrar) | ||
|
||
let instance = try? api.pigeonDelegate.pigeonDefaultConstructor(pigeonApi: api) | ||
XCTAssertNotNil(instance) | ||
} | ||
|
||
func testCompanionAdSlotFilled() { | ||
let api = TestCompanionDelegateApi() | ||
let instance = CompanionDelegateImpl(api: api) | ||
let slot = IMACompanionAdSlot(view: UIView()) | ||
let filled = true | ||
instance.companionSlot(slot, filled: filled) | ||
|
||
XCTAssertEqual(api.companionAdSlotFilledArgs, [slot, filled]) | ||
} | ||
|
||
func testCompanionSlotWasClicked() { | ||
let api = TestCompanionDelegateApi() | ||
let instance = CompanionDelegateImpl(api: api) | ||
let slot = IMACompanionAdSlot(view: UIView()) | ||
instance.companionSlotWasClicked(slot) | ||
|
||
XCTAssertEqual(api.companionSlotWasClickedArgs, [slot]) | ||
} | ||
} | ||
|
||
class TestCompanionDelegateApi: PigeonApiProtocolIMACompanionDelegate { | ||
var companionAdSlotFilledArgs: [AnyHashable?]? = nil | ||
var companionSlotWasClickedArgs: [AnyHashable?]? = nil | ||
|
||
func companionAdSlotFilled( | ||
pigeonInstance pigeonInstanceArg: IMACompanionDelegate, slot slotArg: IMACompanionAdSlot, | ||
filled filledArg: Bool, | ||
completion: @escaping (Result<Void, interactive_media_ads.PigeonError>) -> Void | ||
) { | ||
companionAdSlotFilledArgs = [slotArg, filledArg] | ||
} | ||
|
||
func companionSlotWasClicked( | ||
pigeonInstance pigeonInstanceArg: IMACompanionDelegate, slot slotArg: IMACompanionAdSlot, | ||
completion: @escaping (Result<Void, interactive_media_ads.PigeonError>) -> Void | ||
) { | ||
companionSlotWasClickedArgs = [slotArg] | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...interactive_media_ads/Sources/interactive_media_ads/CompanionAdSlotProxyAPIDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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 Foundation | ||
import GoogleInteractiveMediaAds | ||
import UIKit | ||
|
||
/// ProxyApi implementation for [IMACompanionAdSlot]. | ||
/// | ||
/// This class may handle instantiating native object instances that are attached to a Dart instance | ||
/// or handle method calls on the associated native class or an instance of that class. | ||
class CompanionAdSlotProxyAPIDelegate: PigeonApiDelegateIMACompanionAdSlot { | ||
func pigeonDefaultConstructor(pigeonApi: PigeonApiIMACompanionAdSlot, view: UIView) throws | ||
-> IMACompanionAdSlot | ||
{ | ||
return IMACompanionAdSlot(view: view) | ||
} | ||
|
||
func size(pigeonApi: PigeonApiIMACompanionAdSlot, view: UIView, width: Int64, height: Int64) | ||
throws -> IMACompanionAdSlot | ||
{ | ||
return IMACompanionAdSlot(view: view, width: Int(width), height: Int(height)) | ||
} | ||
|
||
func view(pigeonApi: PigeonApiIMACompanionAdSlot, pigeonInstance: IMACompanionAdSlot) throws | ||
-> UIView | ||
{ | ||
return pigeonInstance.view | ||
} | ||
|
||
func setDelegate( | ||
pigeonApi: PigeonApiIMACompanionAdSlot, pigeonInstance: IMACompanionAdSlot, | ||
delegate: IMACompanionDelegate? | ||
) throws { | ||
pigeonInstance.delegate = delegate | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...teractive_media_ads/Sources/interactive_media_ads/CompanionDelegateProxyAPIDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 Foundation | ||
import GoogleInteractiveMediaAds | ||
|
||
/// Implementation of `IMACompanionDelegate` that calls to Dart in callback methods. | ||
class CompanionDelegateImpl: NSObject, IMACompanionDelegate { | ||
let api: PigeonApiProtocolIMACompanionDelegate | ||
|
||
init(api: PigeonApiProtocolIMACompanionDelegate) { | ||
self.api = api | ||
} | ||
|
||
func companionSlot(_ slot: IMACompanionAdSlot, filled: Bool) { | ||
api.companionAdSlotFilled(pigeonInstance: self, slot: slot, filled: filled) { _ in } | ||
} | ||
|
||
func companionSlotWasClicked(_ slot: IMACompanionAdSlot) { | ||
api.companionSlotWasClicked(pigeonInstance: self, slot: slot) { _ in } | ||
} | ||
} | ||
|
||
/// ProxyApi implementation for [IMACompanionDelegate]. | ||
/// | ||
/// This class may handle instantiating native object instances that are attached to a Dart instance | ||
/// or handle method calls on the associated native class or an instance of that class. | ||
class CompanionDelegateProxyAPIDelegate: PigeonApiDelegateIMACompanionDelegate { | ||
func pigeonDefaultConstructor(pigeonApi: PigeonApiIMACompanionDelegate) throws | ||
-> IMACompanionDelegate | ||
{ | ||
return CompanionDelegateImpl(api: pigeonApi) | ||
} | ||
} |
Oops, something went wrong.