Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
dagger2
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
funnelbit
April 20, 2015
560
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
dagger2
funnelbit
April 20, 2015
More Decks by funnelbit
See All by funnelbit
Hatena Engineer Seminar #9
funnelbit
5
7.5k
droidkaigi-2017-renovation
funnelbit
10
11k
Dart
funnelbit
0
300
BottomBarAndSnackBar
funnelbit
0
550
Dagger2 Optional bindings
funnelbit
0
620
WearableRecyclerView
funnelbit
1
850
QucikSettingsTileAPI
funnelbit
0
390
Mobile Vision
funnelbit
0
490
AwarenessAPI
funnelbit
0
170
Featured
See All Featured
BBQ
matthewcrist
89
10k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
sira's awesome portfolio website redesign presentation
elsirapls
0
340
GraphQLとの向き合い方2022年版
quramy
50
15k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Designing for Timeless Needs
cassininazir
1
450
From π to Pie charts
rasagy
0
320
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
180
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
490
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
580
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
390
Transcript
%BHHFS JEGVOOFMCJU
ࣗݾհ w JEGVOOFMCJU ଜɹྋ w גࣜձࣾͯͳ w ΞϓϦέʔγϣϯΤϯδχΞ w
ڈ͔ΒΞϓϦ։ൃΛ࢝Ίͨ
%BHHFS
%BHHFS w IUUQTHJUIVCDPNHPPHMFEBHHFS w %*ίϯςφ w 4RVBSF͕։ൃͯͨ͠%BHHFSͷHPPHMFGPSL w ਖ਼ࣜ൛ ͍ͭઌϦϦʔε
w ։ൃ൛ͷ4/"14)05
%BHHFSͷϝϦοτ w ίϯύΠϧ࣌ʹίʔυੜ͠ґଘղܾ w KBWBYJOKFDU"OOPUBUJPOΛ༻ w ։ൃ͕׆ൃ
%BHHFS ༻ྫ
ߏΠϝʔδ .PEVMF &OUSZ.BOBHFS "DUJWJUZ &OUSZ.BOBHFS "QQMJDBUJPO $PNQPOFOU "1*$MJFOU
௨৴෦ public class BkumaFormalServiceProvider implements BkumaServiceProvider { … @Override public
BkumaService getService() { OkHttpClient client = new OkHttpClient(); RestAdapter restAdapter = new RestAdapter.Builder() .setClient(new OkClient(client)) .setEndpoint(BkumaService.END_POINT) .build(); return restAdapter.create(BkumaService.class); } …
.PEVMF͔Β*OKFDU @Module public class BkumaModule { private final BkumaService mBkumaService;
public BkumaModule(BkumaGirlsApplication application) { mBkumaService = new BkumaFormalServiceProvider(application .getApplicationContext()).getService(); @Provides @Singleton EntryManager provideEntryManager() { return new EntryManager(mBkumaService); } … public class MainActivity extends ActionBarActivity { @Inject EntryManager mEntryManager; @Override protected void onCreate(Bundle savedInstanceState) { … ((BkumaGirlsApplication)getApplication()).component() .inject(this); } … ௨৴෦
$PNQPOFOUΛ࡞Δ public class BKUMAGirlsApplication extends Application { @Singleton @Component(modules =
BkumaModule.class) public interface ApplicationComponent { void inject(MainActivity mainActivity); } private ApplicationComponent mComponent; @Override public void onCreate() { mComponent = DaggerBKUMAGirlsApplication_ApplicationComponent.builder() .bkumaModule(new BkumaModule(this)) .build(); } public ApplicationComponent component() { return mComponent; } }
%BHHFS ༻ྫ ςετ
.PEVMF ςετ @Module public class BkumaTestModule { private final BkumaService
mBkumaService; … public BkumaTestModule(InstrumentationTestCase instrumentationTestCase) { mBkumaService = new BkumaMockServiceProvider(mInstrumentationTestCase .getInstrumentation().getContext()).getService(); } @Provides EntryManager provideEntryManager() { return new EntryManager(mBkumaService); } … 5FTU༻ #LVNB4FSWJDF
௨৴෦ʢςετʣ @Override public BkumaService getService() { RestAdapter restAdapter = new
RestAdapter .Builder() .setEndpoint(BkumaService.END_POINT) .build(); MockRestAdapter mockRestAdapter = MockRestAdapter.from(restAdapter); mockRestAdapter.setDelay(0); …(ଓ͖·͢) 5FTU༻.PDL
௨৴෦ʢςετʣ … BkumaService bkumaService = new BkumaService() { @Override public
void getTopEntries(@Query("limit") int limit, Callback<List<EntryResponse>> callback) { callback.success( TestUtils.createDummyEntry(mContext, limit), createDummyJsonResponse() ); } }); return mockRestAdapter.create( BkumaService.class, bkumaService ); %VNNZ 3FTQPOTF
*OKFDU ςετ public class BkumaEntryManagerTest extends InstrumentationTestCase { … @Inject
EntryManager mEntryManager; … public testGetEntries() { assertEquals( "ΤϯτϦऔಘͰ͖͍ͯΔ", false, mEntryManager.getEntries().isEmpty()); } }
·ͱΊ w ςελϒϧͳίʔυ͕࡞Γ͍͢ w *OTUBODFཧ͕͘͢͠ͳΔ w "DUJWJUZͷ࠶ੜ࣌ͳͲʹޮ͍ͯ͘Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠