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

Side by Side Diff: content/browser/media/media_internals_unittest.cc

Issue 12207089: Cleanup: Remove deprecated base::Value methods from contents. Use base::Value too. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/media/media_internals.h" 5 #include "content/browser/media/media_internals.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/browser/media/media_internals.h"
11 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread.h"
12 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
14 13
15 namespace content { 14 namespace content {
16 namespace { 15 namespace {
17 16
18 class MockObserverBaseClass { 17 class MockObserverBaseClass {
19 public: 18 public:
20 ~MockObserverBaseClass() {} 19 ~MockObserverBaseClass() {}
21 virtual void OnUpdate(const string16& javascript) = 0; 20 virtual void OnUpdate(const string16& javascript) = 0;
22 }; 21 };
23 22
24 class MockMediaInternalsObserver : public MockObserverBaseClass { 23 class MockMediaInternalsObserver : public MockObserverBaseClass {
25 public: 24 public:
26 virtual ~MockMediaInternalsObserver() {} 25 virtual ~MockMediaInternalsObserver() {}
27 MOCK_METHOD1(OnUpdate, void(const string16& javascript)); 26 MOCK_METHOD1(OnUpdate, void(const string16& javascript));
28 }; 27 };
29 28
30 } // namespace 29 } // namespace
31 30
32 class MediaInternalsTest : public testing::Test { 31 class MediaInternalsTest : public testing::Test {
33 public: 32 public:
34 MediaInternalsTest() : io_thread_(BrowserThread::IO, &loop_) {} 33 MediaInternalsTest() : io_thread_(BrowserThread::IO, &loop_) {}
35 DictionaryValue* data() { 34 base::DictionaryValue* data() {
36 return &internals_->data_; 35 return &internals_->data_;
37 } 36 }
38 37
39 void DeleteItem(const std::string& item) { 38 void DeleteItem(const std::string& item) {
40 internals_->DeleteItem(item); 39 internals_->DeleteItem(item);
41 } 40 }
42 41
43 void UpdateItem(const std::string& item, const std::string& property, 42 void UpdateItem(const std::string& item, const std::string& property,
44 Value* value) { 43 base::Value* value) {
45 internals_->UpdateItem("", item, property, value); 44 internals_->UpdateItem("", item, property, value);
46 } 45 }
47 46
48 void SendUpdate(const std::string& function, Value* value) { 47 void SendUpdate(const std::string& function, base::Value* value) {
49 internals_->SendUpdate(function, value); 48 internals_->SendUpdate(function, value);
50 } 49 }
51 50
52 protected: 51 protected:
53 virtual void SetUp() { 52 virtual void SetUp() {
54 internals_.reset(new MediaInternals()); 53 internals_.reset(new MediaInternals());
55 } 54 }
56 55
57 MessageLoop loop_; 56 MessageLoop loop_;
58 TestBrowserThread io_thread_; 57 TestBrowserThread io_thread_;
59 scoped_ptr<MediaInternals> internals_; 58 scoped_ptr<MediaInternals> internals_;
60 }; 59 };
61 60
62 TEST_F(MediaInternalsTest, UpdateAddsNewItem) { 61 TEST_F(MediaInternalsTest, UpdateAddsNewItem) {
63 UpdateItem("some.item", "testing", Value::CreateBooleanValue(true)); 62 UpdateItem("some.item", "testing", new base::FundamentalValue(true));
64 bool testing = false; 63 bool testing = false;
65 std::string id; 64 std::string id;
66 65
67 EXPECT_TRUE(data()->GetBoolean("some.item.testing", &testing)); 66 EXPECT_TRUE(data()->GetBoolean("some.item.testing", &testing));
68 EXPECT_TRUE(testing); 67 EXPECT_TRUE(testing);
69 68
70 EXPECT_TRUE(data()->GetString("some.item.id", &id)); 69 EXPECT_TRUE(data()->GetString("some.item.id", &id));
71 EXPECT_EQ(id, "some.item"); 70 EXPECT_EQ(id, "some.item");
72 } 71 }
73 72
74 TEST_F(MediaInternalsTest, UpdateModifiesExistingItem) { 73 TEST_F(MediaInternalsTest, UpdateModifiesExistingItem) {
75 UpdateItem("some.item", "testing", Value::CreateBooleanValue(true)); 74 UpdateItem("some.item", "testing", new base::FundamentalValue(true));
76 UpdateItem("some.item", "value", Value::CreateIntegerValue(5)); 75 UpdateItem("some.item", "value", new base::FundamentalValue(5));
77 UpdateItem("some.item", "testing", Value::CreateBooleanValue(false)); 76 UpdateItem("some.item", "testing", new base::FundamentalValue(false));
78 bool testing = true; 77 bool testing = true;
79 int value = 0; 78 int value = 0;
80 std::string id; 79 std::string id;
81 80
82 EXPECT_TRUE(data()->GetBoolean("some.item.testing", &testing)); 81 EXPECT_TRUE(data()->GetBoolean("some.item.testing", &testing));
83 EXPECT_FALSE(testing); 82 EXPECT_FALSE(testing);
84 83
85 EXPECT_TRUE(data()->GetInteger("some.item.value", &value)); 84 EXPECT_TRUE(data()->GetInteger("some.item.value", &value));
86 EXPECT_EQ(value, 5); 85 EXPECT_EQ(value, 5);
87 86
(...skipping 22 matching lines...) Expand all
110 109
111 MediaInternals::UpdateCallback callback = base::Bind( 110 MediaInternals::UpdateCallback callback = base::Bind(
112 &MockMediaInternalsObserver::OnUpdate, base::Unretained(observer.get())); 111 &MockMediaInternalsObserver::OnUpdate, base::Unretained(observer.get()));
113 112
114 internals_->AddUpdateCallback(callback); 113 internals_->AddUpdateCallback(callback);
115 internals_->RemoveUpdateCallback(callback); 114 internals_->RemoveUpdateCallback(callback);
116 SendUpdate("fn", data()); 115 SendUpdate("fn", data());
117 } 116 }
118 117
119 TEST_F(MediaInternalsTest, DeleteRemovesItem) { 118 TEST_F(MediaInternalsTest, DeleteRemovesItem) {
120 Value* out; 119 base::Value* out;
121 120
122 UpdateItem("some.item", "testing", Value::CreateNullValue()); 121 UpdateItem("some.item", "testing", base::Value::CreateNullValue());
123 EXPECT_TRUE(data()->Get("some.item", &out)); 122 EXPECT_TRUE(data()->Get("some.item", &out));
124 EXPECT_TRUE(data()->Get("some", &out)); 123 EXPECT_TRUE(data()->Get("some", &out));
125 124
126 DeleteItem("some.item"); 125 DeleteItem("some.item");
127 EXPECT_FALSE(data()->Get("some.item", &out)); 126 EXPECT_FALSE(data()->Get("some.item", &out));
128 EXPECT_TRUE(data()->Get("some", &out)); 127 EXPECT_TRUE(data()->Get("some", &out));
129 128
130 DeleteItem("some"); 129 DeleteItem("some");
131 EXPECT_FALSE(data()->Get("some.item", &out)); 130 EXPECT_FALSE(data()->Get("some.item", &out));
132 EXPECT_FALSE(data()->Get("some", &out)); 131 EXPECT_FALSE(data()->Get("some", &out));
133 } 132 }
134 133
135 } // namespace content 134 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_internals_proxy.cc ('k') | content/browser/renderer_host/pepper/pepper_tcp_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698