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

Unified Diff: android_webview/native/aw_media_url_interceptor_unittest.cc

Issue 415043006: [Android WebView] AwMediaUrlInterceptor to handle media assets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/native/aw_media_url_interceptor.cc ('k') | android_webview/native/webview_native.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_media_url_interceptor_unittest.cc
diff --git a/android_webview/native/aw_media_url_interceptor_unittest.cc b/android_webview/native/aw_media_url_interceptor_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..be519e515b5e032095e9811d9d06dbbe27ec1c39
--- /dev/null
+++ b/android_webview/native/aw_media_url_interceptor_unittest.cc
@@ -0,0 +1,73 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "android_webview/native/aw_media_url_interceptor.h"
+#include "base/memory/scoped_ptr.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::Test;
+
+namespace android_webview {
+
+namespace {
+
+// Sentinel value to check whether the fields have been set.
+const int UNSET_VALUE = -1;
+
+class AwMediaUrlInterceptorTest : public Test {
+ public:
+ AwMediaUrlInterceptorTest()
+ : fd_(UNSET_VALUE), offset_(UNSET_VALUE), size_(UNSET_VALUE),
+ url_interceptor_(new AwMediaUrlInterceptor()){
+ }
+ protected:
+ int fd_;
+ int64 offset_;
+ int64 size_;
+ scoped_ptr<AwMediaUrlInterceptor> url_interceptor_;
+};
+
+} // namespace
+
+TEST_F(AwMediaUrlInterceptorTest, TestInterceptValidAssetUrl) {
+ // This asset file exists in the android_webview_unittests-debug.apk.
+ // See gyp rule android_webview_unittests_apk.
+ const std::string valid_asset_url(
+ "file:///android_asset/asset_file.ogg");
+
+ ASSERT_TRUE(url_interceptor_->Intercept(
+ valid_asset_url, &fd_, &offset_, &size_));
+ EXPECT_NE(UNSET_VALUE, fd_);
+ EXPECT_NE(UNSET_VALUE, offset_);
+ EXPECT_NE(UNSET_VALUE, size_);
+}
+
+TEST_F(AwMediaUrlInterceptorTest, TestInterceptInvalidAssetUrl) {
+ // This asset file does not exist in the android_webview_unittests-debug.apk.
+ // See gyp rule android_webview_unittests_apk.
+ const std::string invalid_asset_url(
+ "file:///android_asset/file_does_not_exist.ogg");
+
+ ASSERT_FALSE(url_interceptor_->Intercept(
+ invalid_asset_url, &fd_, &offset_, &size_));
+ EXPECT_EQ(UNSET_VALUE, fd_);
+ EXPECT_EQ(UNSET_VALUE, offset_);
+ EXPECT_EQ(UNSET_VALUE, size_);
+}
+
+TEST_F(AwMediaUrlInterceptorTest, TestInterceptNonAssetUrl) {
+ // This url does not refer to an asset in the apk.
+ const std::string non_asset_url("file:///sdcard/file.txt");
+
+ ASSERT_FALSE(url_interceptor_->Intercept(
+ non_asset_url, &fd_, &offset_, &size_));
+ EXPECT_EQ(UNSET_VALUE, fd_);
+ EXPECT_EQ(UNSET_VALUE, offset_);
+ EXPECT_EQ(UNSET_VALUE, size_);
+}
+
+} // namespace android_webview
« no previous file with comments | « android_webview/native/aw_media_url_interceptor.cc ('k') | android_webview/native/webview_native.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698