Skip to content

Commit

Permalink
Merge branch 'main' of github.com:flutter/packages into ima_android_b…
Browse files Browse the repository at this point in the history
…asemanager
  • Loading branch information
bparrishMines committed Oct 28, 2024
2 parents d4eec6c + c658ca2 commit e073910
Show file tree
Hide file tree
Showing 11 changed files with 1,090 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/interactive_media_ads/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

* Adds remaining methods for internal wrapper of the Android native `BaseManager`.

## 0.2.2+14

* Adds internal wrapper for iOS native `IMACompanionAdSlot` and `IMACompanionDelegate`.

## 0.2.2+13

* Adds internal wrapper for Android native `Ad`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
8F977DD92C2C8C6A00A90D4B /* AdLoadingErrorDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F977DD82C2C8C6A00A90D4B /* AdLoadingErrorDataTests.swift */; };
8F977DDB2C2C8D2E00A90D4B /* AdsLoadedDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F977DDA2C2C8D2E00A90D4B /* AdsLoadedDataTests.swift */; };
8FC919922CA5D86F00188068 /* FriendlyObstructionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FC919912CA5D86F00188068 /* FriendlyObstructionTests.swift */; };
8FFF0C182CC1A7F300A7CB98 /* CompanionAdSlotProxyApiTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFF0C172CC1A7F300A7CB98 /* CompanionAdSlotProxyApiTests.swift */; };
8FFF0C1A2CC1A97B00A7CB98 /* CompanionDelegateProxyApiTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFF0C192CC1A97B00A7CB98 /* CompanionDelegateProxyApiTests.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
Expand Down Expand Up @@ -87,6 +89,8 @@
8F977DD82C2C8C6A00A90D4B /* AdLoadingErrorDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdLoadingErrorDataTests.swift; sourceTree = "<group>"; };
8F977DDA2C2C8D2E00A90D4B /* AdsLoadedDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdsLoadedDataTests.swift; sourceTree = "<group>"; };
8FC919912CA5D86F00188068 /* FriendlyObstructionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FriendlyObstructionTests.swift; sourceTree = "<group>"; };
8FFF0C172CC1A7F300A7CB98 /* CompanionAdSlotProxyApiTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanionAdSlotProxyApiTests.swift; sourceTree = "<group>"; };
8FFF0C192CC1A97B00A7CB98 /* CompanionDelegateProxyApiTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanionDelegateProxyApiTests.swift; 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>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -136,6 +140,8 @@
8F599BBC2C332CFE0090A0DF /* ContentPlayheadTests.swift */,
8F599BBE2C3335B40090A0DF /* ViewControllerTests.swift */,
8F8382A22CBDB4A4007F28E0 /* CompanionAdProxyApiTests.swift */,
8FFF0C172CC1A7F300A7CB98 /* CompanionAdSlotProxyApiTests.swift */,
8FFF0C192CC1A97B00A7CB98 /* CompanionDelegateProxyApiTests.swift */,
);
path = RunnerTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -423,6 +429,8 @@
8F599BBB2C332C010090A0DF /* AdsRequestTests.swift in Sources */,
8F599BB72C3327F10090A0DF /* AdsManagerDelegateTests.swift in Sources */,
8F599BBD2C332CFE0090A0DF /* ContentPlayheadTests.swift in Sources */,
8FFF0C182CC1A7F300A7CB98 /* CompanionAdSlotProxyApiTests.swift in Sources */,
8FFF0C1A2CC1A97B00A7CB98 /* CompanionDelegateProxyApiTests.swift in Sources */,
8F977DCF2C2B99C600A90D4B /* AdDisplayContainerTests.swift in Sources */,
8F599BB52C2DD8EC0090A0DF /* AdsLoaderDelegateTests.swift in Sources */,
8F599BB92C332A320090A0DF /* AdsRenderingSettingsTests.swift in Sources */,
Expand Down
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)
}
}
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]
}
}
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
}
}
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)
}
}
Loading

0 comments on commit e073910

Please sign in to comment.