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

Unified Diff: base/trace_event/memory_dump_manager_unittest.cc

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/memory_dump_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_dump_manager_unittest.cc
diff --git a/base/trace_event/memory_dump_manager_unittest.cc b/base/trace_event/memory_dump_manager_unittest.cc
index 1ba73e624aec83648a9fb5089f876bc1dceafc6b..78be3776c373e49f75613814e4722f683429f65c 100644
--- a/base/trace_event/memory_dump_manager_unittest.cc
+++ b/base/trace_event/memory_dump_manager_unittest.cc
@@ -10,6 +10,7 @@
#include "testing/gtest/include/gtest/gtest.h"
using testing::_;
+using testing::Return;
namespace base {
namespace trace_event {
@@ -48,7 +49,9 @@ class MemoryDumpManagerTest : public testing::Test {
class MockDumpProvider : public MemoryDumpProvider {
public:
- MOCK_METHOD1(DumpInto, void(ProcessMemoryDump* pmd));
+ MOCK_METHOD1(DumpInto, bool(ProcessMemoryDump* pmd));
+
+ const char* GetFriendlyName() const override { return "MockDumpProvider"; }
};
TEST_F(MemoryDumpManagerTest, SingleDumper) {
@@ -64,7 +67,7 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
// Now repeat enabling the memory category and check that the dumper is
// invoked this time.
EnableTracing(kTraceCategory);
- EXPECT_CALL(mdp, DumpInto(_)).Times(3);
+ EXPECT_CALL(mdp, DumpInto(_)).Times(3).WillRepeatedly(Return(true));
for (int i = 0; i < 3; ++i)
mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED);
DisableTracing();
@@ -83,7 +86,7 @@ TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileTracing) {
mdm_->RegisterDumpProvider(&mdp);
EnableTracing(kTraceCategory);
- EXPECT_CALL(mdp, DumpInto(_)).Times(1);
+ EXPECT_CALL(mdp, DumpInto(_)).Times(1).WillRepeatedly(Return(true));
mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED);
mdm_->UnregisterDumpProvider(&mdp);
@@ -100,7 +103,7 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
// Enable only mdp1.
mdm_->RegisterDumpProvider(&mdp1);
EnableTracing(kTraceCategory);
- EXPECT_CALL(mdp1, DumpInto(_)).Times(1);
+ EXPECT_CALL(mdp1, DumpInto(_)).Times(1).WillRepeatedly(Return(true));
EXPECT_CALL(mdp2, DumpInto(_)).Times(0);
mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED);
DisableTracing();
@@ -110,16 +113,38 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
mdm_->RegisterDumpProvider(&mdp2);
EnableTracing(kTraceCategory);
EXPECT_CALL(mdp1, DumpInto(_)).Times(0);
- EXPECT_CALL(mdp2, DumpInto(_)).Times(1);
+ EXPECT_CALL(mdp2, DumpInto(_)).Times(1).WillRepeatedly(Return(true));
mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED);
DisableTracing();
// Enable both mdp1 and mdp2.
mdm_->RegisterDumpProvider(&mdp1);
EnableTracing(kTraceCategory);
- EXPECT_CALL(mdp1, DumpInto(_)).Times(1);
- EXPECT_CALL(mdp2, DumpInto(_)).Times(1);
+ EXPECT_CALL(mdp1, DumpInto(_)).Times(1).WillRepeatedly(Return(true));
+ EXPECT_CALL(mdp2, DumpInto(_)).Times(1).WillRepeatedly(Return(true));
+ mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED);
+ DisableTracing();
+}
+
+// Enable both dump providers, make mdp1 fail and assert that only mdp2 is
+// invoked the 2nd time.
+// FIXME(primiano): remove once crbug.com/461788 gets fixed.
+TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) {
+ MockDumpProvider mdp1;
+ MockDumpProvider mdp2;
+
+ mdm_->RegisterDumpProvider(&mdp1);
+ mdm_->RegisterDumpProvider(&mdp2);
+ EnableTracing(kTraceCategory);
+
+ EXPECT_CALL(mdp1, DumpInto(_)).Times(1).WillRepeatedly(Return(false));
+ EXPECT_CALL(mdp2, DumpInto(_)).Times(1).WillRepeatedly(Return(true));
mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED);
+
+ EXPECT_CALL(mdp1, DumpInto(_)).Times(0);
+ EXPECT_CALL(mdp2, DumpInto(_)).Times(1).WillRepeatedly(Return(false));
+ mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED);
+
DisableTracing();
}
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/memory_dump_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698