summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/android/java/net_errors_java.template11
-rw-r--r--net/android/javatests/src/org/chromium/net/NetErrorsTest.java34
-rw-r--r--net/net.gyp34
3 files changed, 79 insertions, 0 deletions
diff --git a/net/android/java/net_errors_java.template b/net/android/java/net_errors_java.template
new file mode 100644
index 0000000..1da7031
--- /dev/null
+++ b/net/android/java/net_errors_java.template
@@ -0,0 +1,11 @@
+// Copyright (c) 2012 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.
+
+package org.chromium.net;
+
+public class NetError {
+#define NET_ERROR(name, value) public static int ERR_##name = value;
+#include "net/base/net_error_list.h"
+}
+
diff --git a/net/android/javatests/src/org/chromium/net/NetErrorsTest.java b/net/android/javatests/src/org/chromium/net/NetErrorsTest.java
new file mode 100644
index 0000000..266655c
--- /dev/null
+++ b/net/android/javatests/src/org/chromium/net/NetErrorsTest.java
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 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.
+
+/**
+ * Tests to verify that NetError.java is created succesfully.
+ */
+
+package org.chromium.net;
+
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.net.NetError;
+
+import org.chromium.base.test.Feature;
+
+public class NetErrorsTest extends InstrumentationTestCase {
+ // These are manually copied and should be kept in sync with net_error_list.h.
+ private static int IO_PENDING_ERROR = -1;
+ private static int FAILED_ERROR = -2;
+
+ /**
+ * Test whether we can include NetError.java and call to static integers defined in the file.
+ *
+ * @throws Exception
+ */
+ @SmallTest
+ @Feature({"Android-AppBase"})
+ public void testExampleErrorDefined() throws Exception {
+ assertEquals(IO_PENDING_ERROR, NetError.ERR_IO_PENDING);
+ assertEquals(FAILED_ERROR, NetError.ERR_FAILED);
+ }
+} \ No newline at end of file
diff --git a/net/net.gyp b/net/net.gyp
index 33872dc..02ef211 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -2111,6 +2111,7 @@
},
'dependencies': [
'../base/base.gyp:base',
+ 'net_errors_java',
],
'export_dependent_settings': [
'../base/base.gyp:base',
@@ -2136,6 +2137,39 @@
],
'includes': [ '../build/java.gypi' ],
},
+ {
+ # This should be extracted to a gypi file and parameterized if
+ # we have more use cases of using the preprocessor to build java files.
+ 'target_name': 'net_errors_java',
+ 'type': 'none',
+ 'direct_dependent_settings': {
+ 'variables': {
+ 'additional_src_dirs': ['<(SHARED_INTERMEDIATE_DIR)/net/template/'],
+ },
+ },
+ 'actions': [
+ {
+ 'action_name': 'generate_net_errors_java',
+ 'inputs': [
+ 'android/java/net_errors_java.template',
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/net/template/NetError.java',
+ ],
+ 'action': [
+ 'gcc',
+ '-x', 'c-header',
+ '-E', '-P',
+ '-I', '..',
+ '-o',
+ '<@(_outputs)',
+ '<@(_inputs)',
+ ],
+ 'message': 'Preprocessing <(_inputs)',
+ 'process_outputs_as_sources': 1,
+ },
+ ],
+ },
],
}],
# Special target to wrap a gtest_target_type==shared_library