-
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.
[interactive_media_ads] Adds internal wrapper for Android native `Com…
…panionAd` (#7823)
- Loading branch information
1 parent
0c72cf1
commit 9d00fb1
Showing
10 changed files
with
330 additions
and
6 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
32 changes: 32 additions & 0 deletions
32
...android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/CompanionAdProxyApi.kt
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,32 @@ | ||
// 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. | ||
|
||
package dev.flutter.packages.interactive_media_ads | ||
|
||
import com.google.ads.interactivemedia.v3.api.CompanionAd | ||
|
||
/** | ||
* ProxyApi implementation for [CompanionAd]. | ||
* | ||
* <p>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 CompanionAdProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : | ||
PigeonApiCompanionAd(pigeonRegistrar) { | ||
override fun apiFramework(pigeon_instance: CompanionAd): String? { | ||
return pigeon_instance.apiFramework | ||
} | ||
|
||
override fun height(pigeon_instance: CompanionAd): Long { | ||
return pigeon_instance.height.toLong() | ||
} | ||
|
||
override fun resourceValue(pigeon_instance: CompanionAd): String { | ||
return pigeon_instance.resourceValue | ||
} | ||
|
||
override fun width(pigeon_instance: CompanionAd): Long { | ||
return pigeon_instance.width.toLong() | ||
} | ||
} |
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
57 changes: 57 additions & 0 deletions
57
...oid/src/test/kotlin/dev/flutter/packages/interactive_media_ads/CompanionAdProxyApiTest.kt
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,57 @@ | ||
// 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. | ||
|
||
package dev.flutter.packages.interactive_media_ads | ||
|
||
import com.google.ads.interactivemedia.v3.api.CompanionAd | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.whenever | ||
|
||
class CompanionAdProxyApiTest { | ||
@Test | ||
fun apiFramework() { | ||
val api = TestProxyApiRegistrar().getPigeonApiCompanionAd() | ||
|
||
val instance = mock<CompanionAd>() | ||
val value = "myString" | ||
whenever(instance.apiFramework).thenReturn(value) | ||
|
||
assertEquals(value, api.apiFramework(instance)) | ||
} | ||
|
||
@Test | ||
fun height() { | ||
val api = TestProxyApiRegistrar().getPigeonApiCompanionAd() | ||
|
||
val instance = mock<CompanionAd>() | ||
val value = 0 | ||
whenever(instance.height).thenReturn(value) | ||
|
||
assertEquals(value.toLong(), api.height(instance)) | ||
} | ||
|
||
@Test | ||
fun resourceValue() { | ||
val api = TestProxyApiRegistrar().getPigeonApiCompanionAd() | ||
|
||
val instance = mock<CompanionAd>() | ||
val value = "myString" | ||
whenever(instance.resourceValue).thenReturn(value) | ||
|
||
assertEquals(value, api.resourceValue(instance)) | ||
} | ||
|
||
@Test | ||
fun width() { | ||
val api = TestProxyApiRegistrar().getPigeonApiCompanionAd() | ||
|
||
val instance = mock<CompanionAd>() | ||
val value = 0 | ||
whenever(instance.width).thenReturn(value) | ||
|
||
assertEquals(value.toLong(), api.width(instance)) | ||
} | ||
} |
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
Oops, something went wrong.