1
00:00:05,000 --> 00:00:06,300
Welcome back, everyone.

2
00:00:07,100 --> 00:00:10,400
We've now got a class that can produce test data for our database.

3
00:00:11,000 --> 00:00:13,500
The next step is to add it to the menu.

4
00:00:14,160 --> 00:00:16,660
We'll do that in main activity

5
00:00:16,660 --> 00:00:19,660
in the on options item selected function.

6
00:00:28,060 --> 00:00:31,660
We added a generate option to the menu a few videos ago.

7
00:00:32,460 --> 00:00:35,960
But we set its show as action attribute to never.

8
00:00:36,760 --> 00:00:40,060
We'll see how to enable it in debug mode in a moment.

9
00:00:40,560 --> 00:00:43,560
First, I'll add the code that creates our TestData.

10
00:00:44,360 --> 00:00:45,360
It's very short.

11
00:00:45,820 --> 00:00:49,620
All we have to do is call the generateTestData function

12
00:00:49,820 --> 00:00:52,180
and pass it the app's content resolver.

13
00:01:00,180 --> 00:01:03,680
To make our menu visible, we enable it in the

14
00:01:03,680 --> 00:01:05,880
oncreate options menu function.

15
00:01:06,980 --> 00:01:09,480
We only want it enabled for debug builds,

16
00:01:09,840 --> 00:01:13,140
so the code to show the menu item is inside an if block.

17
00:01:28,440 --> 00:01:32,000
The compiler is smart enough to realize that this code won't

18
00:01:32,000 --> 00:01:34,900
be executed except in a debug build

19
00:01:35,100 --> 00:01:37,600
and doesn't compile it for a release build.

20
00:01:37,850 --> 00:01:40,450
Unfortunately, as we'll see in a moment,

21
00:01:40,810 --> 00:01:43,810
the code still has to be valid for all builds.

22
00:01:44,310 --> 00:01:48,610
We can now run the app and make sure our TestData Class is working.

23
00:01:58,410 --> 00:02:01,910
Remember that it loops through all the tasks in the database

24
00:02:02,410 --> 00:02:05,410
and creates a random number of timings for each one.

25
00:02:06,290 --> 00:02:10,490
That means you must have some tasks before using theGenerateData option.

26
00:02:10,990 --> 00:02:13,890
So if you haven't got any tasks in your emulator,

27
00:02:13,890 --> 00:02:15,490
add some before continuing.

28
00:02:15,890 --> 00:02:18,890
Okay. Make sure that logcat's open.

29
00:02:20,550 --> 00:02:24,150
Then go to the menu on the app and choose generate data.

30
00:02:31,150 --> 00:02:34,350
We don't get any feedback when the generation is complete.

31
00:02:34,350 --> 00:02:36,350
It's all a bit basic. That's fine.

32
00:02:36,900 --> 00:02:40,800
We're taking steps to ensure that users never get to see this code.

33
00:02:41,300 --> 00:02:44,400
It's just for us when we're testing and debugging the app.

34
00:02:44,900 --> 00:02:47,900
The logcat shows a load of records being created.

35
00:02:48,400 --> 00:02:50,900
We've got the logging from our content provider,

36
00:02:50,900 --> 00:02:52,900
showing each row being added.

37
00:02:53,560 --> 00:02:56,560
I won't do this, but you could go into the terminal

38
00:02:56,860 --> 00:03:00,060
and use SQLite 3 to examine the data

39
00:03:00,420 --> 00:03:03,420
to make sure there have been some timing records inserted.

40
00:03:03,920 --> 00:03:04,920
But that's looking good.

41
00:03:05,720 --> 00:03:08,220
There's a load of insert entries in the logcat

42
00:03:08,720 --> 00:03:11,720
and it looks like the test data class has done its job.

43
00:03:13,020 --> 00:03:17,520
Having test data available is going to make checking our reports a lot easier,

44
00:03:18,220 --> 00:03:20,820
and we'll start creating the report activity next.

45
00:03:21,810 --> 00:03:23,210
Before I do that though,

46
00:03:23,210 --> 00:03:26,510
I want to show you what I mean about debug and release builds

47
00:03:26,510 --> 00:03:29,760
and also explain that comment about debug code

48
00:03:29,760 --> 00:03:32,760
having to be valid even in a release build.

49
00:03:33,560 --> 00:03:36,560
We'll look at that in the next video. I'll see you there.

