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

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: Disabling broken test 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 17 matching lines...) Expand all
28 void EncodeToken(const std::string& token, 28 void EncodeToken(const std::string& token,
29 bool /* audible */, 29 bool /* audible */,
30 const AudioDirectiveList::SamplesCallback& callback) { 30 const AudioDirectiveList::SamplesCallback& callback) {
31 callback.Run(token, CreateRandomAudioRefCounted(0x1337, 1, 0x7331)); 31 callback.Run(token, CreateRandomAudioRefCounted(0x1337, 1, 0x7331));
32 } 32 }
33 33
34 base::MessageLoop message_loop_; 34 base::MessageLoop message_loop_;
35 scoped_ptr<AudioDirectiveList> directive_list_; 35 scoped_ptr<AudioDirectiveList> directive_list_;
36 }; 36 };
37 37
38 // TODO(rkc): Find and fix the memory leak here. 38 // TODO(rkc): Fix these tests on Windows.
39 #if defined(OS_WIN)
39 #define MAYBE_Basic DISABLED_Basic 40 #define MAYBE_Basic DISABLED_Basic
41 #define MAYBE_OutOfOrderAndMultiple DISABLED_OutOfOrderAndMultiple
42 #else
43 #define MAYBE_Basic Basic
44 #define MAYBE_OutOfOrderAndMultiple OutOfOrderAndMultiple
45 #endif
40 46
41 TEST_F(AudioDirectiveListTest, MAYBE_Basic) { 47 TEST_F(AudioDirectiveListTest, MAYBE_Basic) {
42 const base::TimeDelta kZeroTtl = base::TimeDelta::FromMilliseconds(0); 48 const base::TimeDelta kZeroTtl = base::TimeDelta::FromMilliseconds(0);
43 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331); 49 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331);
44 50
45 directive_list_->AddTransmitDirective("token1", "op_id1", kZeroTtl); 51 directive_list_->AddTransmitDirective("token1", "op_id1", kZeroTtl);
46 directive_list_->AddTransmitDirective("token2", "op_id2", kLargeTtl); 52 directive_list_->AddTransmitDirective("token2", "op_id2", kLargeTtl);
47 directive_list_->AddTransmitDirective("token3", "op_id1", kZeroTtl); 53 directive_list_->AddTransmitDirective("token3", "op_id1", kZeroTtl);
48 54
49 EXPECT_EQ("token2", directive_list_->GetNextTransmit()->token); 55 EXPECT_EQ("token2", directive_list_->GetNextTransmit()->token);
50 56
51 directive_list_->AddReceiveDirective("op_id1", kZeroTtl); 57 directive_list_->AddReceiveDirective("op_id1", kZeroTtl);
52 directive_list_->AddReceiveDirective("op_id3", kZeroTtl); 58 directive_list_->AddReceiveDirective("op_id3", kZeroTtl);
53 directive_list_->AddReceiveDirective("op_id3", kLargeTtl); 59 directive_list_->AddReceiveDirective("op_id3", kLargeTtl);
54 directive_list_->AddReceiveDirective("op_id7", kZeroTtl); 60 directive_list_->AddReceiveDirective("op_id7", kZeroTtl);
55 61
56 EXPECT_EQ("op_id3", directive_list_->GetNextReceive()->op_id); 62 EXPECT_EQ("op_id3", directive_list_->GetNextReceive()->op_id);
57 } 63 }
58 64
59 // TODO(rkc): Find out why this is breaking on bots and fix it.
60 #define MAYBE_OutOfOrderAndMultiple DISABLED_OutOfOrderAndMultiple
61
62 TEST_F(AudioDirectiveListTest, MAYBE_OutOfOrderAndMultiple) { 65 TEST_F(AudioDirectiveListTest, MAYBE_OutOfOrderAndMultiple) {
63 const base::TimeDelta kZeroTtl = base::TimeDelta::FromMilliseconds(0); 66 const base::TimeDelta kZeroTtl = base::TimeDelta::FromMilliseconds(0);
64 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331); 67 const base::TimeDelta kLargeTtl = base::TimeDelta::FromSeconds(0x7331);
65 68
66 EXPECT_EQ(NULL, directive_list_->GetNextTransmit().get()); 69 EXPECT_EQ(NULL, directive_list_->GetNextTransmit().get());
67 EXPECT_EQ(NULL, directive_list_->GetNextReceive().get()); 70 EXPECT_EQ(NULL, directive_list_->GetNextReceive().get());
68 71
69 directive_list_->AddTransmitDirective("token1", "op_id1", kZeroTtl); 72 directive_list_->AddTransmitDirective("token1", "op_id1", kZeroTtl);
70 directive_list_->AddTransmitDirective("token2", "op_id2", kLargeTtl); 73 directive_list_->AddTransmitDirective("token2", "op_id2", kLargeTtl);
71 directive_list_->AddTransmitDirective("token3", "op_id1", kLargeTtl); 74 directive_list_->AddTransmitDirective("token3", "op_id1", kLargeTtl);
72 75
73 // Should keep getting the directive till it expires or we add a newer one. 76 // Should keep getting the directive till it expires or we add a newer one.
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("token3", directive_list_->GetNextTransmit()->token);
76 EXPECT_EQ("token3", directive_list_->GetNextTransmit()->token); 79 EXPECT_EQ("token3", directive_list_->GetNextTransmit()->token);
77 EXPECT_EQ(NULL, directive_list_->GetNextReceive().get()); 80 EXPECT_EQ(NULL, directive_list_->GetNextReceive().get());
78 81
79 directive_list_->AddReceiveDirective("op_id1", kLargeTtl); 82 directive_list_->AddReceiveDirective("op_id1", kLargeTtl);
80 directive_list_->AddReceiveDirective("op_id3", kZeroTtl); 83 directive_list_->AddReceiveDirective("op_id3", kZeroTtl);
81 directive_list_->AddReceiveDirective("op_id3", kLargeTtl); 84 directive_list_->AddReceiveDirective("op_id3", kLargeTtl);
82 directive_list_->AddReceiveDirective("op_id7", kLargeTtl); 85 directive_list_->AddReceiveDirective("op_id7", kLargeTtl);
83 86
84 // Should keep getting the directive till it expires or we add a newer one. 87 // Should keep getting the directive till it expires or we add a newer one.
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 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id);
87 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id); 90 EXPECT_EQ("op_id7", directive_list_->GetNextReceive()->op_id);
88 } 91 }
89 92
90 } // namespace copresence 93 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698