| OLD | NEW | 
|   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 "android_webview/native/aw_media_url_interceptor.h" | 
 |   6  | 
 |   7 #include <memory> | 
|   5 #include <string> |   8 #include <string> | 
|   6  |   9  | 
|   7 #include "android_webview/native/aw_media_url_interceptor.h" |  | 
|   8 #include "base/memory/scoped_ptr.h" |  | 
|   9  |  | 
|  10 #include "testing/gtest/include/gtest/gtest.h" |  10 #include "testing/gtest/include/gtest/gtest.h" | 
|  11  |  11  | 
|  12 using testing::Test; |  12 using testing::Test; | 
|  13  |  13  | 
|  14 namespace android_webview { |  14 namespace android_webview { | 
|  15  |  15  | 
|  16 namespace { |  16 namespace { | 
|  17  |  17  | 
|  18 // Sentinel value to check whether the fields have been set. |  18 // Sentinel value to check whether the fields have been set. | 
|  19 const int UNSET_VALUE = -1; |  19 const int UNSET_VALUE = -1; | 
|  20  |  20  | 
|  21 class AwMediaUrlInterceptorTest : public Test { |  21 class AwMediaUrlInterceptorTest : public Test { | 
|  22  public: |  22  public: | 
|  23    AwMediaUrlInterceptorTest() |  23    AwMediaUrlInterceptorTest() | 
|  24        : fd_(UNSET_VALUE), offset_(UNSET_VALUE), size_(UNSET_VALUE), |  24        : fd_(UNSET_VALUE), offset_(UNSET_VALUE), size_(UNSET_VALUE), | 
|  25          url_interceptor_(new AwMediaUrlInterceptor()){ |  25          url_interceptor_(new AwMediaUrlInterceptor()){ | 
|  26    } |  26    } | 
|  27  protected: |  27  protected: | 
|  28    int fd_; |  28    int fd_; | 
|  29    int64_t offset_; |  29    int64_t offset_; | 
|  30    int64_t size_; |  30    int64_t size_; | 
|  31    scoped_ptr<AwMediaUrlInterceptor> url_interceptor_; |  31    std::unique_ptr<AwMediaUrlInterceptor> url_interceptor_; | 
|  32 }; |  32 }; | 
|  33  |  33  | 
|  34 }  // namespace |  34 }  // namespace | 
|  35  |  35  | 
|  36 TEST_F(AwMediaUrlInterceptorTest, TestInterceptValidAssetUrl) { |  36 TEST_F(AwMediaUrlInterceptorTest, TestInterceptValidAssetUrl) { | 
|  37   // This asset file exists in the android_webview_unittests-debug.apk. |  37   // This asset file exists in the android_webview_unittests-debug.apk. | 
|  38   // See gyp rule android_webview_unittests_apk. |  38   // See gyp rule android_webview_unittests_apk. | 
|  39   const std::string valid_asset_url( |  39   const std::string valid_asset_url( | 
|  40       "file:///android_asset/asset_file.ogg"); |  40       "file:///android_asset/asset_file.ogg"); | 
|  41  |  41  | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|  64   const std::string non_asset_url("file:///sdcard/file.txt"); |  64   const std::string non_asset_url("file:///sdcard/file.txt"); | 
|  65  |  65  | 
|  66   ASSERT_FALSE(url_interceptor_->Intercept( |  66   ASSERT_FALSE(url_interceptor_->Intercept( | 
|  67       non_asset_url, &fd_, &offset_, &size_)); |  67       non_asset_url, &fd_, &offset_, &size_)); | 
|  68   EXPECT_EQ(UNSET_VALUE, fd_); |  68   EXPECT_EQ(UNSET_VALUE, fd_); | 
|  69   EXPECT_EQ(UNSET_VALUE, offset_); |  69   EXPECT_EQ(UNSET_VALUE, offset_); | 
|  70   EXPECT_EQ(UNSET_VALUE, size_); |  70   EXPECT_EQ(UNSET_VALUE, size_); | 
|  71 } |  71 } | 
|  72  |  72  | 
|  73 }  // namespace android_webview |  73 }  // namespace android_webview | 
| OLD | NEW |