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

Issue 10996005: Use gtest failures and EXPECTS instead of returning a failure enum in test target base/test/test_sh… (Closed)

Created:
8 years, 2 months ago by gab
Modified:
8 years, 2 months ago
Reviewers:
brettw, robertshield
CC:
chromium-reviews, grt+watch_chromium.org, erikwright+watch_chromium.org
Visibility:
Public.

Description

Use gtest failures and EXPECTS instead of returning a failure enum in test target base/test/test_shortcut_win.cc BUG=148539 TEST=base_unittests.exe --gtest_filter=ShortcutTest* installer_util_unittests.exe --gtest_filter=ShellUtilShortcutTest* unit_tests --gtest_filter=ProfileShortcutManagerTest* Locally tried a test meant to fail for every property: TEST_F(ShortcutTest, CreateShortcutVerifyPropertiesWrong) { ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( link_file_, link_properties_, base::win::SHORTCUT_CREATE_ALWAYS)); base::win::ShortcutProperties wrong_properties = link_properties_; wrong_properties.set_target(FilePath(L"g:\\src\\component\\.gclient")); wrong_properties.set_working_dir(temp_dir_2_.path()); wrong_properties.set_arguments(string16()); wrong_properties.set_description(L"foo"); wrong_properties.set_icon(temp_dir_2_.path().Append(L"joe.ico"), 8); wrong_properties.set_app_id(L"JOE"); wrong_properties.set_dual_mode(true); base::win::ValidateShortcut(link_file_, wrong_properties); } And got expected failure output for every property: [ RUN ] ShortcutTest.CreateShortcutVerifyPropertiesWrong g:\src\component\src\base\test\test_shortcut_win.cc(54): error: Value of: long_actual_path Actual: G:\src\temp\scoped_dir14192_645\Target 1.txt Expected: long_expected_path Which is: g:\src\component\.gclient g:\src\component\src\base\test\test_shortcut_win.cc(54): error: Value of: long_actual_path Actual: G:\src\temp\scoped_dir14192_645 Expected: long_expected_path Which is: G:\src\temp\scoped_dir14192_27681 g:\src\component\src\base\test\test_shortcut_win.cc(95): error: Value of: read_arguments Actual: L"--magic --awesome" Expected: properties.arguments Which is: L"" g:\src\component\src\base\test\test_shortcut_win.cc(101): error: Value of: read_description Actual: L"Chrome is awesome." Expected: properties.description Which is: L"foo" g:\src\component\src\base\test\test_shortcut_win.cc(43): error: Expected: (0U) != (::GetLongPathNameW( expected_path.val ue().c_str(), long_expected_path_chars, 260)), actual: 0 vs 0 Failed to get LongPathName of G:\src\temp\scoped_dir14192_27681\joe.ico g:\src\component\src\base\test\test_shortcut_win.cc(108): error: Value of: read_icon_index Actual: 4 Expected: properties.icon_index Which is: 8 g:\src\component\src\base\test\test_shortcut_win.cc(129): error: Value of: read_app_id Actual: L"Chrome" Expected: properties.app_id Which is: L"JOE" g:\src\component\src\base\test\test_shortcut_win.cc(138): error: Value of: static_cast<bool>(read_dual_mode) Actual: false Expected: properties.dual_mode Which is: true [ FAILED ] ShortcutTest.CreateShortcutVerifyPropertiesWrong (37 ms) Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=158909

Patch Set 1 : #

Total comments: 6

Patch Set 2 : address robertshield's comments #

Patch Set 3 : ASSERTs instead of EXPECTs where desired #

Patch Set 4 : No ASSERTs in test support targets #

Unified diffs Side-by-side diffs Delta from patch set Stats (+161 lines, -184 lines) Patch
M base/test/test_shortcut_win.h View 2 1 chunk +4 lines, -17 lines 0 comments Download
M base/test/test_shortcut_win.cc View 1 2 3 3 chunks +80 lines, -67 lines 0 comments Download
M base/win/shortcut_unittest.cc View 6 chunks +7 lines, -14 lines 0 comments Download
M chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc View 1 2 3 13 chunks +52 lines, -53 lines 0 comments Download
M chrome/installer/util/shell_util_unittest.cc View 10 chunks +18 lines, -33 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
robertshield
http://codereview.chromium.org/10996005/diff/2001/base/test/test_shortcut_win.cc File base/test/test_shortcut_win.cc (right): http://codereview.chromium.org/10996005/diff/2001/base/test/test_shortcut_win.cc#newcode87 base/test/test_shortcut_win.cc:87: UTF16ToUTF8(shortcut_path.value())).c_str()); I don't see any other precedent in the ...
8 years, 2 months ago (2012-09-25 21:06:34 UTC) #1
gab
Indeed, thanks for making the CL better :). PTAL Cheers, Gab http://codereview.chromium.org/10996005/diff/2001/base/test/test_shortcut_win.cc File base/test/test_shortcut_win.cc (right): ...
8 years, 2 months ago (2012-09-25 22:10:00 UTC) #2
robertshield
lgtm
8 years, 2 months ago (2012-09-25 23:47:05 UTC) #3
gab
Thanks, @brettw: base OWNER approval + chrome/browser/profiles side-effect (feel free to add sail@ if you ...
8 years, 2 months ago (2012-09-26 03:03:06 UTC) #4
gab
I was using ASSERTs to do control flow (ASSERTs kindly return only from the current ...
8 years, 2 months ago (2012-09-26 16:23:28 UTC) #5
robertshield
LGTM++ Thanks for doing this :-)
8 years, 2 months ago (2012-09-26 16:55:45 UTC) #6
brettw
lgtm rubbertamp
8 years, 2 months ago (2012-09-26 18:07:37 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/gab@chromium.org/10996005/4004
8 years, 2 months ago (2012-09-26 18:09:26 UTC) #8
commit-bot: I haz the power
Sorry for I got bad news for ya. Compile failed with a clobber build. Your ...
8 years, 2 months ago (2012-09-26 18:25:59 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/gab@chromium.org/10996005/4004
8 years, 2 months ago (2012-09-26 18:28:00 UTC) #10
commit-bot: I haz the power
Sorry for I got bad news for ya. Compile failed with a clobber build. Your ...
8 years, 2 months ago (2012-09-26 18:36:05 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/gab@chromium.org/10996005/4004
8 years, 2 months ago (2012-09-26 18:56:34 UTC) #12
commit-bot: I haz the power
8 years, 2 months ago (2012-09-26 22:21:09 UTC) #13
Change committed as 158909

Powered by Google App Engine
This is Rietveld 408576698