Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Issue 6525056: Add unit tests for BackgroundApplicationListModel (Closed)

Created:
9 years, 10 months ago by The wrong rickcam account
Modified:
9 years, 7 months ago
CC:
chromium-reviews, Paweł Hajdan Jr.
Visibility:
Public.

Description

Add unit tests for BackgroundApplicationListModel BUG=73178 TEST=unittests This adds two tests for the basic list-management functionality of the BackgroundApplicationListManager. The first minimizes testing logic with explicit adding and removing of Background Apps and other extensions. The second does more extensive testing over a large series of operations that add and remove Background App and other extensions. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=75332

Patch Set 1 #

Patch Set 2 : Rolling back some changes to BackgroundApplicationListModel that turned out to be unneeded. #

Patch Set 3 : Rolling back one more change to BackgroundApplicationListModel that turned out to be unneeded. #

Patch Set 4 : Removed some whitespace. Renamed GenerateRandomName to be GenerateRandomExtensionName. #

Patch Set 5 : Tweaking whitespace and comments. Assigned bug number for TODO. #

Total comments: 18

Patch Set 6 : Incorporating code review comments #

Total comments: 11

Patch Set 7 : Cleaning up integer use. Also tweaked logic for remove-when-empty case to be more readable. #

Total comments: 5

Patch Set 8 : one more round of CR #

Unified diffs Side-by-side diffs Delta from patch set Stats (+243 lines, -2 lines) Patch
M chrome/browser/background_application_list_model.h View 1 2 1 chunk +1 line, -2 lines 0 comments Download
A chrome/browser/background_application_list_model_unittest.cc View 1 2 3 4 5 6 7 1 chunk +241 lines, -0 lines 0 comments Download
M chrome/chrome_tests.gypi View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
The wrong rickcam account
Please take a look.
9 years, 10 months ago (2011-02-16 18:07:03 UTC) #1
Andrew T Wilson (Slow)
http://codereview.chromium.org/6525056/diff/5001/chrome/browser/background_application_list_model_unittest.cc File chrome/browser/background_application_list_model_unittest.cc (right): http://codereview.chromium.org/6525056/diff/5001/chrome/browser/background_application_list_model_unittest.cc#newcode37 chrome/browser/background_application_list_model_unittest.cc:37: return FilePath(FILE_PATH_LITERAL("c:\\foo")); To avoid having platform-dependent code here, can ...
9 years, 10 months ago (2011-02-16 18:45:46 UTC) #2
The wrong rickcam account
Please take another look. http://codereview.chromium.org/6525056/diff/5001/chrome/browser/background_application_list_model_unittest.cc File chrome/browser/background_application_list_model_unittest.cc (right): http://codereview.chromium.org/6525056/diff/5001/chrome/browser/background_application_list_model_unittest.cc#newcode37 chrome/browser/background_application_list_model_unittest.cc:37: return FilePath(FILE_PATH_LITERAL("c:\\foo")); On 2011/02/16 18:45:46, ...
9 years, 10 months ago (2011-02-16 22:39:20 UTC) #3
Andrew T Wilson (Slow)
LGTM if you address my comments below. http://codereview.chromium.org/6525056/diff/7001/chrome/browser/background_application_list_model_unittest.cc File chrome/browser/background_application_list_model_unittest.cc (right): http://codereview.chromium.org/6525056/diff/7001/chrome/browser/background_application_list_model_unittest.cc#newcode9 chrome/browser/background_application_list_model_unittest.cc:9: #include <set> ...
9 years, 10 months ago (2011-02-17 05:56:46 UTC) #4
The wrong rickcam account
Please take another look even though you said LGTM :-) I made the changes that ...
9 years, 10 months ago (2011-02-17 18:24:01 UTC) #5
Andrew T Wilson (Slow)
LGTM with two nits. http://codereview.chromium.org/6525056/diff/13001/chrome/browser/background_application_list_model_unittest.cc File chrome/browser/background_application_list_model_unittest.cc (right): http://codereview.chromium.org/6525056/diff/13001/chrome/browser/background_application_list_model_unittest.cc#newcode169 chrome/browser/background_application_list_model_unittest.cc:169: static size_t uniqueness = 0; ...
9 years, 10 months ago (2011-02-17 18:43:14 UTC) #6
The wrong rickcam account
9 years, 10 months ago (2011-02-17 23:50:55 UTC) #7
Moving forward with dcommit now.  Thanks.

http://codereview.chromium.org/6525056/diff/13001/chrome/browser/background_a...
File chrome/browser/background_application_list_model_unittest.cc (right):

http://codereview.chromium.org/6525056/diff/13001/chrome/browser/background_a...
chrome/browser/background_application_list_model_unittest.cc:169: static size_t
uniqueness = 0;
On 2011/02/17 18:43:14, Andrew T Wilson wrote:
> Actually, I think this should just be an int, since uniqueness doesn't contain
> the size of anything.

Done.

http://codereview.chromium.org/6525056/diff/13001/chrome/browser/background_a...
chrome/browser/background_application_list_model_unittest.cc:194:
srandom(RANDOM_SEED);
srand/rand are considered more standard(*) to substituting them in for
srandom/random.

(*)  In particular, MS Windows builds fail with srandom/random even when
including <cstdlib> as directed by relevant man pages.  NOTE: The man pages say
that srandom/random are POSIX, but I found people commenting on the web saying
that srandom/random are missing from various places on MS Windows because they
are not standard.

http://codereview.chromium.org/6525056/diff/13001/chrome/browser/background_a...
chrome/browser/background_application_list_model_unittest.cc:213: } else if
(extensions.empty()) {
On 2011/02/17 18:43:14, Andrew T Wilson wrote:
> nit: It was more readable before when this was just an else { // maybe remove
an
> extension
> 
> Now you have:
> 
> if (random() % 2) {
>    ... do stuff ...
> } else if (extensions.empty()) {
>    ... more stuff...
> } else {
>    ... more ...
> }
> 
> And it's not clear what extensions.empty() has to do with the first if.
> 
> I think it's clearer as:
> 
> if (random() % 2) { // Add an extension
>    ...
> } else { // Maybe remove an extension if there are any.
>   if (extensions.empty()) {
>     ...asserts...
>   } else {
>     // Randomly select an extension to remove
>   }
> }
> 
> Anyhow, this is a total nit so feel free to ignore.

Done.  I'm going with the theory that the reader is the better judge of
readability :-)

Powered by Google App Engine
This is Rietveld 408576698