CB-5346 Fix and cleanup broken Android unit test

- Found stale cordova.js in the test project. Changed ant script to copy in
  a fresh one in the pre-build stage. Removed stale copies from git, added
  to .gitignore. This is what was causing the test failure when sending
  javascript to the webview.
- Found almost-stale copy of device plugin, did the same as above.
- Fixed spacing in log messages in CordovaWebView.
- Updated README.md with current information.
- Removed dollar signs that were previously accidently appended to the license.
- Added cordova version to html pages, next to the other metadata.
- Fix incorrect separator in the viewport meta tag.
- Changed old-style <log> tag to <preference name="loglevel"> in config.xml.
- In BackButtonMultiPageTest, increased the TIMEOUT so the deviceready event
  can trigger the referenced javascript, improved the setup() method to
  explicitly load the starting point.
This commit is contained in:
Marcel Kinard 2013-11-11 16:19:01 -05:00
parent c5767eb545
commit b895a0c335
31 changed files with 281 additions and 2658 deletions

3
.gitignore vendored
View File

@ -19,6 +19,9 @@ example
./test
test/bin
test/assets/www/.tmp*
test/assets/www/cordova.js
test/cordova/plugins/org.apache.cordova.device/www/device.js
test/cordova/plugins/org.apache.cordova.device/src/android/Device.java
tmp/**
.metadata
tmp/**/*

View File

@ -874,7 +874,7 @@ public class CordovaWebView extends WebView {
{
WebHistoryItem item = currentList.getItemAtIndex(i);
String url = item.getUrl();
LOG.d(TAG, "The URL at index: " + Integer.toString(i) + "is " + url );
LOG.d(TAG, "The URL at index: " + Integer.toString(i) + " is " + url );
}
}
@ -888,7 +888,7 @@ public class CordovaWebView extends WebView {
String url = item.getUrl();
String currentUrl = this.getUrl();
LOG.d(TAG, "The current URL is: " + currentUrl);
LOG.d(TAG, "The URL at item 0 is:" + url);
LOG.d(TAG, "The URL at item 0 is: " + url);
return currentUrl.equals(url);
}
return false;

View File

@ -255,5 +255,5 @@
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
</application>
</application>
</manifest>

View File

@ -24,11 +24,11 @@ These tests are designed to verify Android native features and other Android spe
## Initial Setup ##
Before running the tests, they need to be set up.
There really isn't any manual setup to do. The ant script takes care of that.
You don't even need to compile cordova-x.y.z.jar or copy it, because
project.properties has a library reference to ../framework.
0. Copy cordova-x.y.z.jar into libs directory
To run from command line:
To run manually from command line:
0. Build by entering `ant debug install`
0. Run tests by clicking on "CordovaTest" icon on device
@ -38,7 +38,7 @@ To run from Eclipse:
0. Import Android project into Eclipse
0. Ensure Project properties "Java Build Path" includes the lib/cordova-x.y.z.jar
0. Create run configuration if not already created
0. Run tests
0. Run As -> Android JUnit Test
## Automatic Runs ##
@ -46,5 +46,3 @@ Once you have installed the test, you can launch and run the tests
automatically with the below command:
adb shell am instrument -w org.apache.cordova.test/android.test.InstrumentationTestRunner
(Optionally, you can also run in Eclipse)

View File

@ -1,20 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
@ -27,6 +27,7 @@ $
<body onload="init();" id="stage" class="theme">
<h1>Cordova Android Tests</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>

View File

@ -1,20 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
@ -27,6 +27,7 @@ $
<body onload="init();" id="stage" class="theme">
<h1>Cordova Android Tests</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>

View File

@ -1,20 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
@ -27,6 +27,7 @@ $
<body onload="init();" id="stage" class="theme">
<h1>Cordova Android Tests</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>

View File

@ -84,17 +84,10 @@ $
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
<h1>Events</h1>
<div id="info">
<h4>
Platform: <span id="platform"> &nbsp;</span>, Version: <span
id="version">&nbsp;</span>
</h4>
<h4>
UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
</h4>
<h4>
Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span>
</h4>
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
Press "Home" button, then return to this app to see pause/resume.<br>

View File

@ -84,17 +84,10 @@ $
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
<h1>Events</h1>
<div id="info">
<h4>
Platform: <span id="platform"> &nbsp;</span>, Version: <span
id="version">&nbsp;</span>
</h4>
<h4>
UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
</h4>
<h4>
Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span>
</h4>
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
<h4>Press "Back" button to return to Page 1.</h4>

View File

@ -29,6 +29,7 @@
<body onload="init();" id="stage" class="theme">
<h1>Background Color Test</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;

View File

@ -29,6 +29,7 @@
<body onload="init();" id="stage" class="theme">
<h1>Basic Auth</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,7 @@
<body onload="init();" id="stage" class="theme">
<h1>Full Screen Test</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;

View File

@ -1,19 +1,19 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.$
-->
This is an error page.

View File

@ -1,21 +1,21 @@
<!DOCTYPE HTML>
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
@ -33,6 +33,7 @@ $
<body onload="init();" id="stage" class="theme">
<h1>IFrame</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;

View File

@ -1,21 +1,21 @@
<!DOCTYPE HTML>
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
@ -29,6 +29,7 @@ $
<body onload="init();" id="stage" class="theme">
<h1>IFrame window</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;

View File

@ -19,7 +19,7 @@
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta name="viewport" content="width=320, user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Cordova Tests</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">

View File

@ -1,20 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>

View File

@ -1,20 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>

View File

@ -1,20 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>

View File

@ -1,20 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>

View File

@ -1,21 +1,21 @@
<!DOCTYPE HTML>
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
@ -47,6 +47,7 @@ $
document.getElementById("width").innerHTML = screen.width;
document.getElementById("height").innerHTML = screen.height;
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
document.getElementById("cordova").innerHTML = device.cordova;
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
@ -84,17 +85,10 @@ $
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
<h1>Events</h1>
<div id="info">
<h4>
Platform: <span id="platform"> &nbsp;</span>, Version: <span
id="version">&nbsp;</span>
</h4>
<h4>
UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
</h4>
<h4>
Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span>
</h4>
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
<h4>Test 1</h4>

View File

@ -1,20 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE HTML>
<html>
@ -44,6 +44,7 @@ $
document.getElementById("version").innerHTML = device.version;
document.getElementById("uuid").innerHTML = device.uuid;
document.getElementById("name").innerHTML = device.name;
document.getElementById("cordova").innerHTML = device.cordova;
document.getElementById("width").innerHTML = screen.width;
document.getElementById("height").innerHTML = screen.height;
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
@ -84,17 +85,10 @@ $
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
<h1>Events</h1>
<div id="info">
<h4>
Platform: <span id="platform"> &nbsp;</span>, Version: <span
id="version">&nbsp;</span>
</h4>
<h4>
UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span>
</h4>
<h4>
Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span>
</h4>
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div id="info">
You should see<br>

View File

@ -1,21 +1,21 @@
<!DOCTYPE HTML>
<!--
Licensed to the Apache Software Foundation (ASF) under one$
or more contributor license agreements. See the NOTICE file$
distributed with this work for additional information$
regarding copyright ownership. The ASF licenses this file$
to you under the Apache License, Version 2.0 (the$
"License"); you may not use this file except in compliance$
with the License. You may obtain a copy of the License at$
$
http://www.apache.org/licenses/LICENSE-2.0$
$
Unless required by applicable law or agreed to in writing,$
software distributed under the License is distributed on an$
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
KIND, either express or implied. See the License for the$
specific language governing permissions and limitations$
under the License.$
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
@ -29,6 +29,7 @@ $
<body onload="init();" id="stage" class="theme">
<h1>Menu Test</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;

View File

@ -29,6 +29,7 @@ $
<body onload="init();" id="stage" class="theme">
<h1>Whitelist Page 1</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;

View File

@ -29,6 +29,7 @@ $
<body onload="init();" id="stage" class="theme">
<h1>Whitelist Page 2</h1>
<div id="info">
<h4>Cordova: <span id="cordova"> &nbsp;</span></h4>
<h4>Platform: <span id="platform"> &nbsp;</span>, Version: <span id="version">&nbsp;</span></h4>
<h4>UUID: <span id="uuid"> &nbsp;</span>, Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;

View File

@ -66,9 +66,34 @@
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
<!-- copy in the current cordova.js file from the parent project -->
<copy file="../framework/assets/www/cordova.js"
todir="assets/www"
preservelastmodified="true"
failonerror="true"
verbose="true" />
<!-- copy the latest device plugin from the parent's peer -->
<fail message="Need to have cordova-plugin-device cloned." >
<condition>
<not>
<available file="../../cordova-plugin-device" type="dir" />
</not>
</condition>
</fail>
<copy file="../../cordova-plugin-device/www/device.js"
tofile="cordova/plugins/org.apache.cordova.device/www/device.js"
preservelastmodified="true"
failonerror="true"
verbose="true" />
<copy file="../../cordova-plugin-device/src/android/Device.java"
tofile="cordova/plugins/org.apache.cordova.device/src/android/Device.java"
preservelastmodified="true"
failonerror="true"
verbose="true" />
</target>
<!--
<target name="-pre-compile">
</target>

View File

@ -1,200 +0,0 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova.device;
import java.util.TimeZone;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.LOG;
import org.apache.cordova.CordovaInterface;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.provider.Settings;
import android.telephony.TelephonyManager;
public class Device extends CordovaPlugin {
public static final String TAG = "Device";
public static String cordovaVersion = "dev"; // Cordova version
public static String platform = "Android"; // Device OS
public static String uuid; // Device UUID
BroadcastReceiver telephonyReceiver = null;
/**
* Constructor.
*/
public Device() {
}
/**
* Sets the context of the Command. This can then be used to do things like
* get file paths associated with the Activity.
*
* @param cordova The context of the main Activity.
* @param webView The CordovaWebView Cordova is running in.
*/
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
Device.uuid = getUuid();
this.initTelephonyReceiver();
}
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackContext The callback id used when calling back into JavaScript.
* @return True if the action was valid, false if not.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equals("getDeviceInfo")) {
JSONObject r = new JSONObject();
r.put("uuid", Device.uuid);
r.put("version", this.getOSVersion());
r.put("platform", Device.platform);
r.put("cordova", Device.cordovaVersion);
r.put("model", this.getModel());
callbackContext.success(r);
}
else {
return false;
}
return true;
}
/**
* Unregister receiver.
*/
public void onDestroy() {
this.cordova.getActivity().unregisterReceiver(this.telephonyReceiver);
}
//--------------------------------------------------------------------------
// LOCAL METHODS
//--------------------------------------------------------------------------
/**
* Listen for telephony events: RINGING, OFFHOOK and IDLE
* Send these events to all plugins using
* CordovaActivity.onMessage("telephone", "ringing" | "offhook" | "idle")
*/
private void initTelephonyReceiver() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
//final CordovaInterface mycordova = this.cordova;
this.telephonyReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// If state has changed
if ((intent != null) && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
if (intent.hasExtra(TelephonyManager.EXTRA_STATE)) {
String extraData = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (extraData.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
LOG.i(TAG, "Telephone RINGING");
webView.postMessage("telephone", "ringing");
}
else if (extraData.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
LOG.i(TAG, "Telephone OFFHOOK");
webView.postMessage("telephone", "offhook");
}
else if (extraData.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
LOG.i(TAG, "Telephone IDLE");
webView.postMessage("telephone", "idle");
}
}
}
}
};
// Register the receiver
this.cordova.getActivity().registerReceiver(this.telephonyReceiver, intentFilter);
}
/**
* Get the OS name.
*
* @return
*/
public String getPlatform() {
return Device.platform;
}
/**
* Get the device's Universally Unique Identifier (UUID).
*
* @return
*/
public String getUuid() {
String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
return uuid;
}
/**
* Get the Cordova version.
*
* @return
*/
public String getCordovaVersion() {
return Device.cordovaVersion;
}
public String getModel() {
String model = android.os.Build.MODEL;
return model;
}
public String getProductName() {
String productname = android.os.Build.PRODUCT;
return productname;
}
/**
* Get the OS version.
*
* @return
*/
public String getOSVersion() {
String osversion = android.os.Build.VERSION.RELEASE;
return osversion;
}
public String getSDKVersion() {
@SuppressWarnings("deprecation")
String sdkversion = android.os.Build.VERSION.SDK;
return sdkversion;
}
public String getTimeZoneID() {
TimeZone tz = TimeZone.getDefault();
return (tz.getID());
}
}

View File

@ -1,77 +0,0 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var argscheck = require('cordova/argscheck'),
channel = require('cordova/channel'),
utils = require('cordova/utils'),
exec = require('cordova/exec'),
cordova = require('cordova');
channel.createSticky('onCordovaInfoReady');
// Tell cordova channel to wait on the CordovaInfoReady event
channel.waitForInitialization('onCordovaInfoReady');
/**
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
* phone, etc.
* @constructor
*/
function Device() {
this.available = false;
this.platform = null;
this.version = null;
this.uuid = null;
this.cordova = null;
this.model = null;
var me = this;
channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
//ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
//TODO: CB-5105 native implementations should not return info.cordova
var buildLabel = cordova.version;
me.available = true;
me.platform = info.platform;
me.version = info.version;
me.uuid = info.uuid;
me.cordova = buildLabel;
me.model = info.model;
channel.onCordovaInfoReady.fire();
},function(e) {
me.available = false;
utils.alert("[ERROR] Error initializing Cordova: " + e);
});
});
}
/**
* Get device info
*
* @param {Function} successCallback The function to call when the heading data is available
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
*/
Device.prototype.getInfo = function(successCallback, errorCallback) {
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
};
module.exports = new Device();

View File

@ -9,7 +9,7 @@
</author>
<access origin="*.apache.org" />
<content src="index.html" />
<log level="DEBUG" />
<preference name="loglevel" value="DEBUG" />
<preference name="useBrowserHistory" value="true" />
<preference name="exit-on-suspend" value="false" />
<feature name="Activity">

View File

@ -32,7 +32,7 @@ import android.widget.LinearLayout;
public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<backbuttonmultipage> {
private int TIMEOUT = 1000;
private int TIMEOUT = 2000;
backbuttonmultipage testActivity;
private FrameLayout containerView;
private LinearLayout innerContainer;
@ -40,7 +40,7 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
public BackButtonMultiPageTest() {
super("org.apache.cordova.test", backbuttonmultipage.class);
super(backbuttonmultipage.class);
}
protected void setUp() throws Exception {
@ -49,11 +49,15 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
innerContainer = (LinearLayout) containerView.getChildAt(0);
testView = (CordovaWebView) innerContainer.getChildAt(0);
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/index.html");
sleep();
}
public void testPreconditions(){
assertNotNull(innerContainer);
assertNotNull(testView);
String url = testView.getUrl();
assertTrue(url.endsWith("index.html"));
}
public void testViaHref() {