|
|
DescriptionCleanup IndexedDBIO unit tests using GoogleMock.
Previous tests had the following limitations:
1. Not all ASSERT/EXPECT's were within the test functions.
2. Not verifying that OpenLevelDB was ever called.
3. Unused MockErrorLevelDBFactory::expect_destroy.
4. Explicitly doing things (like functionXXX called) which we get for
free by using GoogleMock.
BUG=388012
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=283995
Patch Set 1 #
Total comments: 6
Patch Set 2 : Rebased on master for trybot #Patch Set 3 : exporting LevelDBFactories for shared library support #Patch Set 4 : Added gmock dependency to GN file #Patch Set 5 : Allowing path to gmock (testing for AOSP) #Patch Set 6 : Added gmock dependency for AOSP #Patch Set 7 : Moved mock_leveldb_factory.cc into content_tests #Patch Set 8 : Removed gmock dependency for AOSP #Patch Set 9 : not exporting MockLevelDBFactory #Messages
Total messages: 64 (0 generated)
Note: the tests *did* work before. This is just some refactoring to clean up the tests and enhance them slightly.
https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... File content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc (right): https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc:82: leveldb::Status open_error_; Initialize open_error_. https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc:101: EXPECT_CALL(mock_leveldb_factory, DestroyLevelDB(_)).Times(Exactly(1)); What causes these expectations to be verified? I don't see a destructor that would do it...is there some magic, or are we missing a derivation that leads back to FunctionMockerBase somehow?
https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... File content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc (right): https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc:82: leveldb::Status open_error_; On 2014/06/24 23:57:47, ericu wrote: > Initialize open_error_. The default constructor for leveldb::Status constructs an OK() object. Do you still want to be explicit about this? https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc:101: EXPECT_CALL(mock_leveldb_factory, DestroyLevelDB(_)).Times(Exactly(1)); On 2014/06/24 23:57:47, ericu wrote: > What causes these expectations to be verified? I don't see a destructor that > would do it...is there some magic, or are we missing a derivation that leads > back to FunctionMockerBase somehow? I believe it's when the mock object (mock_leveldb_factory in this case) goes out of scope and is destroyed. If I enter the wrong numerical values they will cause the test to fail.
https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... File content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc (right): https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc:82: leveldb::Status open_error_; On 2014/06/25 00:05:28, cmumford wrote: > On 2014/06/24 23:57:47, ericu wrote: > > Initialize open_error_. > > The default constructor for leveldb::Status constructs an OK() object. Do you > still want to be explicit about this? Oops--no, nevermind. https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc:101: EXPECT_CALL(mock_leveldb_factory, DestroyLevelDB(_)).Times(Exactly(1)); On 2014/06/25 00:05:28, cmumford wrote: > On 2014/06/24 23:57:47, ericu wrote: > > What causes these expectations to be verified? I don't see a destructor that > > would do it...is there some magic, or are we missing a derivation that leads > > back to FunctionMockerBase somehow? > > I believe it's when the mock object (mock_leveldb_factory in this case) goes out > of scope and is destroyed. If I enter the wrong numerical values they will cause > the test to fail. mock_leveldb_factory is a content::MockLevelDBFactory. Going up its type chain, I can't see any destructor that would do that. Can you show me the call chain that leads to failure?
On 2014/06/25 00:09:43, ericu wrote: > https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... > File content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc > (right): > > https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... > content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc:82: > leveldb::Status open_error_; > On 2014/06/25 00:05:28, cmumford wrote: > > On 2014/06/24 23:57:47, ericu wrote: > > > Initialize open_error_. > > > > The default constructor for leveldb::Status constructs an OK() object. Do you > > still want to be explicit about this? > > Oops--no, nevermind. > > https://codereview.chromium.org/356463008/diff/1/content/browser/indexed_db/i... > content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc:101: > EXPECT_CALL(mock_leveldb_factory, DestroyLevelDB(_)).Times(Exactly(1)); > On 2014/06/25 00:05:28, cmumford wrote: > > On 2014/06/24 23:57:47, ericu wrote: > > > What causes these expectations to be verified? I don't see a destructor > that > > > would do it...is there some magic, or are we missing a derivation that leads > > > back to FunctionMockerBase somehow? > > > > I believe it's when the mock object (mock_leveldb_factory in this case) goes > out > > of scope and is destroyed. If I enter the wrong numerical values they will > cause > > the test to fail. > > mock_leveldb_factory is a content::MockLevelDBFactory. Going up its type chain, > I can't see any destructor that would do that. Can you show me the call chain > that leads to failure? It looks like the MOCK_METHOD*() macros add a variable into their mock class which is compatible with either a default or explicit destructor. Here's the call stack to a failure that I injected. #1 0x000003072a07 base::debug::(anonymous namespace)::StackDumpSignalHandler() #2 0x7f1da0558cb0 <unknown> #3 0x7f1d9ed43425 gsignal #4 0x7f1d9ed46b8b abort #5 0x000001e72074 testing::internal::UntypedFunctionMockerBase::VerifyAndClearExpectation sLocked() #6 0x000001518e64 testing::internal::FunctionMockerBase<>::~FunctionMockerBase() #7 0x000001518865 testing::internal::FunctionMocker<>::~FunctionMocker() #8 0x000001518617 content::MockLevelDBFactory::~MockLevelDBFactory() #9 0x0000009e8522 (anonymous namespace)::IndexedDBIOErrorTest_CleanUpTest_Test::TestBody( ) #10 0x000001eac2f3 testing::internal::HandleSehExceptionsInMethodIfSupported<>() #11 0x000001e9969e testing::internal::HandleExceptionsInMethodIfSupported<>() #12 0x000001e90345 testing::Test::Run() #13 0x000001e90a5b testing::TestInfo::Run() #14 0x000001e9104a testing::TestCase::Run() #15 0x000001e95658 testing::internal::UnitTestImpl::RunAllTests() #16 0x000001ea5003 testing::internal::HandleSehExceptionsInMethodIfSupported<>() #17 0x000001e9b21e testing::internal::HandleExceptionsInMethodIfSupported<>() #18 0x000001e952e4 testing::UnitTest::Run() #19 0x000001e21f91 RUN_ALL_TESTS() #20 0x000001e21017 base::TestSuite::Run() #21 0x000001d8c81d content::UnitTestTestSuite::Run() #22 0x0000010721f2 base::internal::RunnableAdapter<>::Run() #23 0x00000107215c base::internal::InvokeHelper<>::MakeItSo() #24 0x00000107210a base::internal::Invoker<>::Run() #25 0x0000015bb5de base::Callback<>::Run() #26 0x000001e16a20 base::(anonymous namespace)::LaunchUnitTestsInternal() #27 0x000001e16717 base::LaunchUnitTests() #28 0x000001071ed0 main #29 0x7f1d9ed2e76d __libc_start_main #30 0x0000004da5e9 <unknown>
lgtm
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/1
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) android_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_clang_dbg/bui...) linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_clang_...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...) mac_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/mac_chromium_compile_...) win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_clang_dbg/bui...)
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/1
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) android_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_clang_dbg/bui...) linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_clang_...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...) mac_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/mac_chromium_compile_...) win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...)
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/1
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) android_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_clang_dbg/bui...) linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_clang_...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...) mac_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/mac_chromium_compile_...) win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) android_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_clang_dbg/bui...) linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...)
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/1
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) android_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_clang_dbg/bui...) linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_clang_...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...) mac_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/mac_chromium_compile_...) win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) android_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_clang_dbg/bui...) linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_clang_...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...)
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/1
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) android_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_clang_dbg/bui...) linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_clang_...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...) mac_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/mac_chromium_compile_...) win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: mac_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/mac_chromium_compile_...)
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/20001
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/40001
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...)
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/40001
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) linux_chromium_gn_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_gn_rel...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_aosp on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...)
On 2014/06/27 14:17:58, I haz the power (commit-bot) wrote: > Try jobs failed on following builders: > android_aosp on tryserver.chromium > (http://build.chromium.org/p/tryserver.chromium/builders/android_aosp/builds/8...) ericu@ I've built this CL on Linux/Android/Mac/Windows. From what I can see these errors are problems with the commit bots. Do you see an error? If not can you manually push this through for me?
+benm for android_webview/buildbot/deps_whitelist.py +avi for content/browser/BUILD.gn
lgtm stamp assuming that deps is correct
-benm, +torne since Ben is OOO till 7/15
Do we really need to add gmock as a dependency of content_browser? That seems wrong; surely only the tests should require it. If this is landed we will have to start merging gmock into the android tree to build WebView and we prefer to keep our dependencies minimal. The WebView build doesn't build the unit tests, so as long as the dependency is in a test target it won't matter...
On 2014/07/14 15:58:09, Torne wrote: > Do we really need to add gmock as a dependency of content_browser? That seems > wrong; surely only the tests should require it. > > If this is landed we will have to start merging gmock into the android tree to > build WebView and we prefer to keep our dependencies minimal. The WebView build > doesn't build the unit tests, so as long as the dependency is in a test target > it won't matter... Thx Torne. You're correct - there was no need for the dependency to be that high - having content_tests depend on gmock was sufficient. But I still think I need this change to deps_whitelist.py though for a full build. Am I correct, or is there a better way to satisfy this dependency for AOSP?
On 2014/07/14 18:46:58, cmumford wrote: > On 2014/07/14 15:58:09, Torne wrote: > > Do we really need to add gmock as a dependency of content_browser? That seems > > wrong; surely only the tests should require it. > > > > If this is landed we will have to start merging gmock into the android tree to > > build WebView and we prefer to keep our dependencies minimal. The WebView > build > > doesn't build the unit tests, so as long as the dependency is in a test target > > it won't matter... > > Thx Torne. You're correct - there was no need for the dependency to be that high > - having content_tests depend on gmock was sufficient. But I still think I need > this change to deps_whitelist.py though for a full build. Am I correct, or is > there a better way to satisfy this dependency for AOSP? There is no "full build" on the AOSP bot; we never build the tests in that configuration.
On 2014/07/14 20:41:06, Torne wrote: > On 2014/07/14 18:46:58, cmumford wrote: > > On 2014/07/14 15:58:09, Torne wrote: > > > Do we really need to add gmock as a dependency of content_browser? That > seems > > > wrong; surely only the tests should require it. > > > > > > If this is landed we will have to start merging gmock into the android tree > to > > > build WebView and we prefer to keep our dependencies minimal. The WebView > > build > > > doesn't build the unit tests, so as long as the dependency is in a test > target > > > it won't matter... > > > > Thx Torne. You're correct - there was no need for the dependency to be that > high > > - having content_tests depend on gmock was sufficient. But I still think I > need > > this change to deps_whitelist.py though for a full build. Am I correct, or is > > there a better way to satisfy this dependency for AOSP? > > There is no "full build" on the AOSP bot; we never build the tests in that > configuration. Thx Torne. I reverted the deps_whitelist.py change and AOSP builds now that dependency is in a target apparently not build by AOSP.
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/140001
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_chromeos_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chrome...) linux_chromium_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_clang_...) linux_chromium_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_rel/bu...) mac_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/mac_chromium_compile_...) mac_chromium_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/mac_chromium_rel/buil...) win8_chromium_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win8_chromium_rel/bui...) win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...) win_chromium_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_rel/buil...) win_chromium_x64_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_x64_rel/...) linux_gpu on tryserver.chromium.gpu (http://build.chromium.org/p/tryserver.chromium.gpu/builders/linux_gpu/builds/...) mac_gpu on tryserver.chromium.gpu (http://build.chromium.org/p/tryserver.chromium.gpu/builders/mac_gpu/builds/28471)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...)
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/140001
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...)
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: win_chromium_compile_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/win_chromium_compile_...)
The CQ bit was checked by cmumford@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cmumford@chromium.org/356463008/160001
Message was sent while issue was closed.
Change committed as 283995 |