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

Side by Side Diff: components/copresence/handlers/audio/audio_directive_list_unittest.cc

Issue 453203002: Fixing memory leak in TimedMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging to HEAD Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/copresence/handlers/audio/audio_directive_list.h" 5 #include "components/copresence/handlers/audio/audio_directive_list.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "components/copresence/test/audio_test_support.h" 10 #include "components/copresence/test/audio_test_support.h"
(...skipping 18 matching lines...) Expand all
29 bool audible, 29 bool audible,
30 const AudioDirectiveList::SamplesCallback& callback) { 30 const AudioDirectiveList::SamplesCallback& callback) {
31 callback.Run( 31 callback.Run(
32 token, audible, CreateRandomAudioRefCounted(0x1337, 1, 0x7331)); 32 token, audible, CreateRandomAudioRefCounted(0x1337, 1, 0x7331));
33 } 33 }
34 34
35 base::MessageLoop message_loop_; 35 base::MessageLoop message_loop_;
36 scoped_ptr<AudioDirectiveList> directive_list_; 36 scoped_ptr<AudioDirectiveList> directive_list_;
37 }; 37 };
38 38
39 // TODO(rkc): Find and fix the memory leak here. 39 // TODO(rkc): Fix errors in these tests. See crbug/402578.
40 #define MAYBE_Basic DISABLED_Basic 40 #define MAYBE_Basic DISABLED_Basic
41 #define MAYBE_OutOfOrderAndMultiple DISABLED_OutOfOrderAndMultiple
41 42
42 TEST_F(AudioDirectiveListTest, MAYBE_Basic) { 43 TEST_F(AudioDirectiveListTest, MAYBE_Basic) {
43 const base::TimeDelta kZeroTtl = base::TimeDelta::FromMilliseconds(0); 44 const base::TimeDelta kZeroTtl = base::TimeDelta::FromMilliseconds(0);
44 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331); 45 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331);
45 46
46 directive_list_->AddTransmitDirective("token1", "op_id1", kZeroTtl); 47 directive_list_->AddTransmitDirective("token1", "op_id1", kZeroTtl);
47 directive_list_->AddTransmitDirective("token2", "op_id2", kLargeTtl); 48 directive_list_->AddTransmitDirective("token2", "op_id2", kLargeTtl);
48 directive_list_->AddTransmitDirective("token3", "op_id1", kZeroTtl); 49 directive_list_->AddTransmitDirective("token3", "op_id1", kZeroTtl);
49 50
50 EXPECT_EQ("token2", directive_list_->GetNextTransmit()->token); 51 EXPECT_EQ("token2", directive_list_->GetNextTransmit()->token);
51 52
52 directive_list_->AddReceiveDirective("op_id1", kZeroTtl); 53 directive_list_->AddReceiveDirective("op_id1", kZeroTtl);
53 directive_list_->AddReceiveDirective("op_id3", kZeroTtl); 54 directive_list_->AddReceiveDirective("op_id3", kZeroTtl);
54 directive_list_->AddReceiveDirective("op_id3", kLargeTtl); 55 directive_list_->AddReceiveDirective("op_id3", kLargeTtl);
55 directive_list_->AddReceiveDirective("op_id7", kZeroTtl); 56 directive_list_->AddReceiveDirective("op_id7", kZeroTtl);
56 57
57 EXPECT_EQ("op_id3", directive_list_->GetNextReceive()->op_id); 58 EXPECT_EQ("op_id3", directive_list_->GetNextReceive()->op_id);
58 } 59 }
59 60
60 // TODO(rkc): Find out why this is breaking on bots and fix it.
61 #define MAYBE_OutOfOrderAndMultiple DISABLED_OutOfOrderAndMultiple
62
63 TEST_F(AudioDirectiveListTest, MAYBE_OutOfOrderAndMultiple) { 61 TEST_F(AudioDirectiveListTest, MAYBE_OutOfOrderAndMultiple) {
64 const base::TimeDelta kZeroTtl = base::TimeDelta::FromMilliseconds(0); 62 const base::TimeDelta kZeroTtl = base::TimeDelta::FromMilliseconds(0);
65 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331); 63 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331);
66 64
67 EXPECT_EQ(NULL, directive_list_->GetNextTransmit().get()); 65 EXPECT_EQ(NULL, directive_list_->GetNextTransmit().get());
68 EXPECT_EQ(NULL, directive_list_->GetNextReceive().get()); 66 EXPECT_EQ(NULL, directive_list_->GetNextReceive().get());
69 67
70 directive_list_->AddTransmitDirective("token1", "op_id1", kZeroTtl); 68 directive_list_->AddTransmitDirective("token1", "op_id1", kZeroTtl);
71 directive_list_->AddTransmitDirective("token2", "op_id2", kLargeTtl); 69 directive_list_->AddTransmitDirective("token2", "op_id2", kLargeTtl);
72 directive_list_->AddTransmitDirective("token3", "op_id1", kLargeTtl); 70 directive_list_->AddTransmitDirective("token3", "op_id1", kLargeTtl);
73 71
74 // Should keep getting the directive till it expires or we add a newer one. 72 // Should keep getting the directive till it expires or we add a newer one.
75 EXPECT_EQ("token3", directive_list_->GetNextTransmit()->token); 73 EXPECT_EQ("token3", directive_list_->GetNextTransmit()->token);
76 EXPECT_EQ("token3", directive_list_->GetNextTransmit()->token); 74 EXPECT_EQ("token3", directive_list_->GetNextTransmit()->token);
77 EXPECT_EQ("token3", directive_list_->GetNextTransmit()->token); 75 EXPECT_EQ("token3", directive_list_->GetNextTransmit()->token);
78 EXPECT_EQ(NULL, directive_list_->GetNextReceive().get()); 76 EXPECT_EQ(NULL, directive_list_->GetNextReceive().get());
79 77
80 directive_list_->AddReceiveDirective("op_id1", kLargeTtl); 78 directive_list_->AddReceiveDirective("op_id1", kLargeTtl);
81 directive_list_->AddReceiveDirective("op_id3", kZeroTtl); 79 directive_list_->AddReceiveDirective("op_id3", kZeroTtl);
82 directive_list_->AddReceiveDirective("op_id3", kLargeTtl); 80 directive_list_->AddReceiveDirective("op_id3", kLargeTtl);
83 directive_list_->AddReceiveDirective("op_id7", kLargeTtl); 81 directive_list_->AddReceiveDirective("op_id7", kLargeTtl);
84 82
85 // Should keep getting the directive till it expires or we add a newer one. 83 // Should keep getting the directive till it expires or we add a newer one.
86 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); 84 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id);
87 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); 85 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id);
88 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); 86 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id);
89 } 87 }
90 88
91 } // namespace copresence 89 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698