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

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

Issue 9845033: Move the MediaObserver getter from ResourceContext to ContentBrowserClient, since we only need to s… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix dcheck Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/media/media_internals.cc ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/media/media_internals.h" 5 #include "chrome/browser/media/media_internals.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h"
8 #include "chrome/browser/media/media_internals_observer.h" 9 #include "chrome/browser/media/media_internals_observer.h"
10 #include "content/test/test_browser_thread.h"
9 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
12 class MockMediaInternalsObserver : public MediaInternalsObserver { 14 class MockMediaInternalsObserver : public MediaInternalsObserver {
13 public: 15 public:
14 MOCK_METHOD1(OnUpdate, void(const string16& javascript)); 16 MOCK_METHOD1(OnUpdate, void(const string16& javascript));
15 }; 17 };
16 18
17 class MediaInternalsTest : public testing::Test { 19 class MediaInternalsTest : public testing::Test {
18 public: 20 public:
21 MediaInternalsTest() : io_thread_(content::BrowserThread::IO, &loop_) {}
19 DictionaryValue* data() { 22 DictionaryValue* data() {
20 return &internals_->data_; 23 return &internals_->data_;
21 } 24 }
22 25
23 void DeleteItem(const std::string& item) { 26 void DeleteItem(const std::string& item) {
24 internals_->DeleteItem(item); 27 internals_->DeleteItem(item);
25 } 28 }
26 29
27 void UpdateItem(const std::string& item, const std::string& property, 30 void UpdateItem(const std::string& item, const std::string& property,
28 Value* value) { 31 Value* value) {
29 internals_->UpdateItem("", item, property, value); 32 internals_->UpdateItem("", item, property, value);
30 } 33 }
31 34
32 void SendUpdate(const std::string& function, Value* value) { 35 void SendUpdate(const std::string& function, Value* value) {
33 internals_->SendUpdate(function, value); 36 internals_->SendUpdate(function, value);
34 } 37 }
35 38
36 protected: 39 protected:
37 virtual void SetUp() { 40 virtual void SetUp() {
38 internals_.reset(new MediaInternals()); 41 internals_.reset(new MediaInternals());
39 } 42 }
43
44 MessageLoop loop_;
45 content::TestBrowserThread io_thread_;
40 scoped_ptr<MediaInternals> internals_; 46 scoped_ptr<MediaInternals> internals_;
41 }; 47 };
42 48
43 TEST_F(MediaInternalsTest, UpdateAddsNewItem) { 49 TEST_F(MediaInternalsTest, UpdateAddsNewItem) {
44 UpdateItem("some.item", "testing", Value::CreateBooleanValue(true)); 50 UpdateItem("some.item", "testing", Value::CreateBooleanValue(true));
45 bool testing = false; 51 bool testing = false;
46 std::string id; 52 std::string id;
47 53
48 EXPECT_TRUE(data()->GetBoolean("some.item.testing", &testing)); 54 EXPECT_TRUE(data()->GetBoolean("some.item.testing", &testing));
49 EXPECT_TRUE(testing); 55 EXPECT_TRUE(testing);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 EXPECT_TRUE(data()->Get("some", &out)); 105 EXPECT_TRUE(data()->Get("some", &out));
100 106
101 DeleteItem("some.item"); 107 DeleteItem("some.item");
102 EXPECT_FALSE(data()->Get("some.item", &out)); 108 EXPECT_FALSE(data()->Get("some.item", &out));
103 EXPECT_TRUE(data()->Get("some", &out)); 109 EXPECT_TRUE(data()->Get("some", &out));
104 110
105 DeleteItem("some"); 111 DeleteItem("some");
106 EXPECT_FALSE(data()->Get("some.item", &out)); 112 EXPECT_FALSE(data()->Get("some.item", &out));
107 EXPECT_FALSE(data()->Get("some", &out)); 113 EXPECT_FALSE(data()->Get("some", &out));
108 } 114 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_internals.cc ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698