Skip to content

Commit

Permalink
refactor: remove m- prefix in classes fields #393
Browse files Browse the repository at this point in the history
Fix tests that use white box and reflection.
  • Loading branch information
ValentinPostindustria committed Mar 29, 2022
1 parent 998f970 commit ac98d25
Show file tree
Hide file tree
Showing 328 changed files with 10,009 additions and 9,496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,14 @@
@RunWith(AndroidJUnit4.class)
public class ExtraTests {

@Rule
public ActivityTestRule<TestActivity> m = new ActivityTestRule<>(TestActivity.class);
@Rule
public GrantPermissionRule mGrant = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION);
@Rule public ActivityTestRule<TestActivity> m = new ActivityTestRule<>(TestActivity.class);
@Rule public GrantPermissionRule grant = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION);
MockWebServer server;
Handler mHandler;
Handler handler;

@Before
public void setUp() {
mHandler = new Handler(Looper.getMainLooper());
handler = new Handler(Looper.getMainLooper());
server = new MockWebServer();
try {
server.start();
Expand All @@ -94,7 +92,7 @@ public void testMultipleDemand() throws Exception {
PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888df0");
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -162,7 +160,7 @@ public MockResponse dispatch(RecordedRequest request) {
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
Host.CUSTOM.setHostUrl(server.url("testPostData").toString());

mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
BannerAdUnit adUnit = new BannerAdUnit("1001-1", 300, 250);
Expand All @@ -187,7 +185,7 @@ public void testSameConfigIdOnDifferentAdObjects() throws Exception {
PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888df0");
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject1 = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -248,7 +246,7 @@ public void testMultipleAdUnitsAllDemandFetched() throws Exception {
PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888df0");
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
// test 0 set up Banner
Expand Down Expand Up @@ -469,7 +467,7 @@ public void testRubiconDemand() throws Exception {
PrebidMobile.setPrebidServerHost(Host.RUBICON);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -503,7 +501,7 @@ public void testAppNexusKeyValueTargeting() throws Exception {
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -537,7 +535,7 @@ public void testAppNexusKeyValueTargeting2() throws Exception {
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -571,7 +569,7 @@ public void testEmptyInvalidPrebidServerAccountId() throws Exception {
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -603,7 +601,7 @@ public void testRubiconEmptyInvalidPrebidServerAccountId() throws Exception {
PrebidMobile.setShareGeoLocation(true);

final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -634,7 +632,7 @@ public void testAppNexusInvalidPrebidServerAccountId() throws Exception {
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -666,7 +664,7 @@ public void testRubiconInvalidPrebidServerAccountId() throws Exception {
PrebidMobile.setShareGeoLocation(true);

final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -697,7 +695,7 @@ public void testEmptyInvalidPrebidServerConfigId() throws Exception {
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -729,7 +727,7 @@ public void testRubiconEmptyInvalidPrebidServerConfigId() throws Exception {
PrebidMobile.setShareGeoLocation(true);

final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -760,7 +758,7 @@ public void testAppNexusInvalidPrebidServerConfigId() throws Exception {
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -792,7 +790,7 @@ public void testRubiconInvalidPrebidServerConfigId() throws Exception {
PrebidMobile.setShareGeoLocation(true);

final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -846,7 +844,7 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -901,7 +899,7 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -949,7 +947,7 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
PrebidMobile.setShareGeoLocation(true);
TargetingParams.setYearOfBirth(2018);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -996,7 +994,7 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
PrebidMobile.setShareGeoLocation(true);
TargetingParams.setYearOfBirth(1989);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -1071,7 +1069,7 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
Host.CUSTOM.setHostUrl(server.url("/sharerealgeo").toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
final OnCompleteListener[] listener = new OnCompleteListener[2];
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down Expand Up @@ -1099,7 +1097,7 @@ public void onComplete(ResultCode resultCode) {
PrebidMobile.setShareGeoLocation(false);
Host.CUSTOM.setHostUrl(server.url("/sharefakegeo").toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
mHandler.post(new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,25 @@ public void onNativeFail(NativeErrorCode errorCode) {
}
});
moPubNative.registerAdRenderer(new MoPubStaticNativeAdRenderer(null));
RequestParameters.Builder mRP = new RequestParameters.Builder();
RequestParameters.Builder requestParams = new RequestParameters.Builder();

// Fetching the demannd using OnCompleteListener
nativeAdUnit.fetchDemand(mRP, new OnCompleteListener() {
nativeAdUnit.fetchDemand(requestParams, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
if (resultCode == ResultCode.SUCCESS) {
moPubNative.makeRequest(mRP.build());
moPubNative.makeRequest(requestParams.build());
} else {
Toast.makeText(XandrNativeInAppMoPubDemoActivity.this, "Native Ad Unit: " + resultCode.name(), Toast.LENGTH_SHORT).show();
Toast.makeText(
XandrNativeInAppMoPubDemoActivity.this,
"Native Ad Unit: " + resultCode.name(),
Toast.LENGTH_SHORT
).show();
}

refreshCount++;
XandrNativeInAppMoPubDemoActivity.this.resultCode = resultCode;
request = mRP.build();
request = requestParams.build();
}
});

Expand All @@ -235,9 +239,9 @@ public void onComplete(ResultCode resultCode, Map<String, String> unmodifiableMa
}
// removing last ","
keywords = keywords.substring(0, keywords.length()-1);
RequestParameters mRP = new RequestParameters.Builder().keywords(keywords).build();
Log.d("Prebid", mRP.getKeywords());
mMoPubNative.makeRequest(mRP);
RequestParameters requestParams = new RequestParameters.Builder().keywords(keywords).build();
Log.d("Prebid", requestParams.getKeywords());
moPubNative.makeRequest(requestParams);
}
Toast.makeText(XandrNativeInAppMoPubDemoActivity.this, "Native Ad Unit: " + resultCode.name(), Toast.LENGTH_SHORT).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import org.junit.runners.model.Statement;

public class RetryRule implements TestRule {
private int mMaxTries;
private int maxTries;

public RetryRule(int maxTries) {
mMaxTries = maxTries;
this.maxTries = maxTries;
}

public Statement apply(Statement base, Description description) {
Expand All @@ -38,17 +38,16 @@ public void evaluate() throws Throwable {
Throwable caughtThrowable = null;

// implement retry logic here
for (int i = 0; i < mMaxTries; i++) {
for (int i = 0; i < maxTries; i++) {
try {
base.evaluate();
return;
}
catch (Throwable t) {
} catch (Throwable t) {
caughtThrowable = t;
System.err.println(description.getDisplayName() + ": run " + (i + 1) + " failed");
}
}
System.err.println(description.getDisplayName() + ": giving up after " + mMaxTries + " failures");
System.err.println(description.getDisplayName() + ": giving up after " + maxTries + " failures");
throw caughtThrowable;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MainActivity : AppCompatActivity(), SdkInitListener {

private val TAG = MainActivity::class.java.simpleName

private lateinit var mProgress: ProgressDialog
private lateinit var progress: ProgressDialog
private lateinit var bottomAppBar: BottomNavigationView
private lateinit var titleText: TextView

Expand Down Expand Up @@ -98,7 +98,7 @@ class MainActivity : AppCompatActivity(), SdkInitListener {

override fun onSDKInit() {
Log.i(TAG, "Prebid rendering SDK initialized successfully")
mProgress.dismiss()
progress.dismiss()
}

fun getIdlingResource(): IdlingResource? {
Expand All @@ -114,11 +114,11 @@ class MainActivity : AppCompatActivity(), SdkInitListener {
}

private fun initProgressDialog() {
mProgress = ProgressDialog(this)
mProgress.setTitle("Please wait")
mProgress.setMessage("Caching video ads")
mProgress.setCancelable(false)
mProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER)
progress = ProgressDialog(this)
progress.setTitle("Please wait")
progress.setMessage("Caching video ads")
progress.setCancelable(false)
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER)
}

private fun initBarNavigation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MoPubRewardedVideoFragment: AdFragment() {

private var rewardedAdUnit: MediationRewardedVideoAdUnit? = null
private val keywordsMap = HashMap<String, String>()
private val mListener = object : MoPubRewardedAdListener {
private val listener = object : MoPubRewardedAdListener {

override fun onRewardedAdLoadSuccess(adUnitId: String) {
btnAdDidLoad.isEnabled = true
Expand Down Expand Up @@ -96,7 +96,7 @@ class MoPubRewardedVideoFragment: AdFragment() {
val builder = SdkConfiguration.Builder(adUnitId)
MoPubRewardedAdManager.init(requireActivity())
MoPubRewardedAdManager.updateActivity(requireActivity())
MoPubRewardedAds.setRewardedAdListener(mListener)
MoPubRewardedAds.setRewardedAdListener(listener)
MoPub.initializeSdk(requireContext(), builder.build()) {
fetchAdUnit(adUnitId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MopubInterstitialFragment : AdFragment() {

private lateinit var mopubInterstitialAdUnit: MediationInterstitialAdUnit
private lateinit var moPubInterstitial: MoPubInterstitial
private val mListener = object : MoPubInterstitial.InterstitialAdListener {
private val listener = object : MoPubInterstitial.InterstitialAdListener {
override fun onInterstitialLoaded(interstitial: MoPubInterstitial) {
btnAdDidLoad?.isEnabled = true
btnLoad?.isEnabled = true
Expand Down Expand Up @@ -98,7 +98,7 @@ class MopubInterstitialFragment : AdFragment() {

private fun initInterstitialView(adUnitId: String, configId: String, title: String) {
moPubInterstitial = MoPubInterstitial(requireActivity(), adUnitId)
moPubInterstitial.interstitialAdListener = mListener
moPubInterstitial.interstitialAdListener = listener

val isVideo = (title.contains("Video", true) && !title.contains("MRAID", true))
val mediationUtils = MoPubInterstitialMediationUtils(moPubInterstitial)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package org.prebid.mobile;

public class BidLog {
private BidLogEntry mLastEntry;
private BidLogEntry lastEntry;

private static BidLog sInstance;
private static BidLog instance;

public static BidLog getInstance() {
if (sInstance == null) {
sInstance = new BidLog();
if (instance == null) {
instance = new BidLog();
}
return sInstance;
return instance;
}

private BidLog() {

}

public BidLogEntry getLastBid() {
return mLastEntry;
return lastEntry;
}

public void setLastEntry(BidLogEntry entry) {
this.mLastEntry = entry;
this.lastEntry = entry;
}

public void cleanLog() {
this.mLastEntry = null;
this.lastEntry = null;
}

public static class BidLogEntry {
Expand Down
Loading

0 comments on commit ac98d25

Please sign in to comment.