| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "media/blink/url_index.h" | 13 #include "media/blink/url_index.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 class UrlIndexTest : public testing::Test { | 18 class UrlIndexTest : public testing::Test { |
| 18 public: | 19 public: |
| 19 UrlIndexTest() : url_index_(nullptr) {} | 20 UrlIndexTest() : url_index_(nullptr) {} |
| 20 | 21 |
| 21 scoped_refptr<UrlData> GetByUrl(const GURL& gurl, | 22 scoped_refptr<UrlData> GetByUrl(const GURL& gurl, |
| 22 UrlData::CORSMode cors_mode) { | 23 UrlData::CORSMode cors_mode) { |
| 23 scoped_refptr<UrlData> ret = url_index_.GetByUrl(gurl, cors_mode); | 24 scoped_refptr<UrlData> ret = url_index_.GetByUrl(gurl, cors_mode); |
| 24 EXPECT_EQ(ret->url(), gurl); | 25 EXPECT_EQ(ret->url(), gurl); |
| 25 EXPECT_EQ(ret->cors_mode(), cors_mode); | 26 EXPECT_EQ(ret->cors_mode(), cors_mode); |
| 26 return ret; | 27 return ret; |
| 27 } | 28 } |
| 28 | 29 |
| 30 // TODO(hubbe): Make UrlIndex take a task_runner_ |
| 31 base::MessageLoop message_loop_; |
| 29 UrlIndex url_index_; | 32 UrlIndex url_index_; |
| 30 }; | 33 }; |
| 31 | 34 |
| 32 TEST_F(UrlIndexTest, SimpleTest) { | 35 TEST_F(UrlIndexTest, SimpleTest) { |
| 33 GURL url1("http://foo.bar.com"); | 36 GURL url1("http://foo.bar.com"); |
| 34 GURL url2("http://foo.bar.com/urgel"); | 37 GURL url2("http://foo.bar.com/urgel"); |
| 35 scoped_refptr<UrlData> a = GetByUrl(url1, UrlData::CORS_UNSPECIFIED); | 38 scoped_refptr<UrlData> a = GetByUrl(url1, UrlData::CORS_UNSPECIFIED); |
| 36 // Make sure it's valid, we still shouldn't get the same one. | 39 // Make sure it's valid, we still shouldn't get the same one. |
| 37 a->Use(); | 40 a->Use(); |
| 38 a->set_range_supported(); | 41 a->set_range_supported(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 c->set_valid_until(valid_until); | 150 c->set_valid_until(valid_until); |
| 148 c->set_last_modified(last_modified); | 151 c->set_last_modified(last_modified); |
| 149 EXPECT_TRUE(c->Valid()); | 152 EXPECT_TRUE(c->Valid()); |
| 150 | 153 |
| 151 // B is still valid, so it should be preferred over C. | 154 // B is still valid, so it should be preferred over C. |
| 152 EXPECT_EQ(b, url_index_.TryInsert(c)); | 155 EXPECT_EQ(b, url_index_.TryInsert(c)); |
| 153 EXPECT_EQ(b, GetByUrl(url, UrlData::CORS_UNSPECIFIED)); | 156 EXPECT_EQ(b, GetByUrl(url, UrlData::CORS_UNSPECIFIED)); |
| 154 } | 157 } |
| 155 | 158 |
| 156 } // namespace media | 159 } // namespace media |
| OLD | NEW |