forked from firebase/flutterfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[firebase_admob] Provide a default MobileAdTargetingInfo for Rewarded…
…VideoAd.load() (firebase#2245)
- Loading branch information
Showing
6 changed files
with
129 additions
and
3 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
106 changes: 106 additions & 0 deletions
106
packages/firebase_admob/example/test_driver/firebase_admob.dart
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,106 @@ | ||
// Copyright 2017 The Chromium 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 'dart:async'; | ||
|
||
import 'package:flutter_driver/driver_extension.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:firebase_admob/firebase_admob.dart'; | ||
|
||
void main() { | ||
final Completer<String> completer = Completer<String>(); | ||
enableFlutterDriverExtension(handler: (_) => completer.future); | ||
tearDownAll(() => completer.complete(null)); | ||
|
||
group('$FirebaseAdMob', () { | ||
test('Initialize Firebase Admob', () async { | ||
expect( | ||
FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId), | ||
completes, | ||
); | ||
}); | ||
|
||
test('$BannerAd', () async { | ||
final Completer<void> adCompleter = Completer<void>(); | ||
|
||
final BannerAd bannerAd = BannerAd( | ||
adUnitId: BannerAd.testAdUnitId, | ||
size: AdSize.banner, | ||
targetingInfo: MobileAdTargetingInfo( | ||
keywords: <String>['foo', 'bar'], | ||
contentUrl: 'http://foo.com/bar.html', | ||
childDirected: true, | ||
nonPersonalizedAds: true, | ||
), | ||
listener: (MobileAdEvent event) { | ||
if (event == MobileAdEvent.loaded) adCompleter.complete(); | ||
}, | ||
); | ||
|
||
await bannerAd.load(); | ||
expect(adCompleter.future, completes); | ||
}); | ||
|
||
test('$InterstitialAd', () async { | ||
final Completer<void> adCompleter = Completer<void>(); | ||
|
||
final InterstitialAd interstitialAd = InterstitialAd( | ||
adUnitId: InterstitialAd.testAdUnitId, | ||
targetingInfo: MobileAdTargetingInfo( | ||
keywords: <String>['foo', 'bar'], | ||
contentUrl: 'http://foo.com/bar.html', | ||
childDirected: true, | ||
nonPersonalizedAds: true, | ||
), | ||
listener: (MobileAdEvent event) { | ||
if (event == MobileAdEvent.loaded) adCompleter.complete(); | ||
}, | ||
); | ||
|
||
await interstitialAd.load(); | ||
expect(adCompleter.future, completes); | ||
}); | ||
|
||
test('$RewardedVideoAd', () async { | ||
// Request without a targeting info | ||
bool hasStartedLoading = await RewardedVideoAd.instance.load( | ||
adUnitId: RewardedVideoAd.testAdUnitId, | ||
); | ||
expect(hasStartedLoading, isTrue); | ||
|
||
// Request with a targeting info | ||
hasStartedLoading = await RewardedVideoAd.instance.load( | ||
adUnitId: RewardedVideoAd.testAdUnitId, | ||
targetingInfo: MobileAdTargetingInfo( | ||
keywords: <String>['foo', 'bar'], | ||
contentUrl: 'http://foo.com/bar.html', | ||
childDirected: true, | ||
nonPersonalizedAds: true, | ||
), | ||
); | ||
expect(hasStartedLoading, isTrue); | ||
}); | ||
|
||
test('$NativeAd', () async { | ||
final Completer<void> adCompleter = Completer<void>(); | ||
|
||
final NativeAd nativeAd = NativeAd( | ||
adUnitId: NativeAd.testAdUnitId, | ||
factoryId: 'adFactoryExample', | ||
targetingInfo: MobileAdTargetingInfo( | ||
keywords: <String>['foo', 'bar'], | ||
contentUrl: 'http://foo.com/bar.html', | ||
childDirected: true, | ||
nonPersonalizedAds: true, | ||
), | ||
listener: (MobileAdEvent event) { | ||
if (event == MobileAdEvent.loaded) adCompleter.complete(); | ||
}, | ||
); | ||
|
||
await nativeAd.load(); | ||
expect(adCompleter.future, completes); | ||
}); | ||
}); | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/firebase_admob/example/test_driver/firebase_admob_test.dart
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,11 @@ | ||
// Copyright 2017 The Chromium 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 'package:flutter_driver/flutter_driver.dart'; | ||
|
||
void main() async { | ||
final FlutterDriver driver = await FlutterDriver.connect(); | ||
await driver.requestData(null, timeout: const Duration(minutes: 1)); | ||
await driver.close(); | ||
} |
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