Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Flutter Inappwebview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
Flutter Inappwebview
Commits
7c5b1a1c
Commit
7c5b1a1c
authored
Nov 13, 2019
by
crazecoder
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
b389760d
dce31242
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
545 additions
and
177 deletions
+545
-177
.idea/workspace.xml
.idea/workspace.xml
+244
-168
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
...flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
+11
-4
example/lib/main.dart
example/lib/main.dart
+0
-3
example/pubspec.yaml
example/pubspec.yaml
+1
-0
example/test/custom_widget_test.dart
example/test/custom_widget_test.dart
+18
-0
example/test/in_app_webview_initial_file_test.dart
example/test/in_app_webview_initial_file_test.dart
+50
-0
example/test/in_app_webview_initial_url_test.dart
example/test/in_app_webview_initial_url_test.dart
+50
-0
example/test/in_app_webview_on_load_resource_test.dart
example/test/in_app_webview_on_load_resource_test.dart
+66
-0
example/test/main_test.dart
example/test/main_test.dart
+43
-0
example/test/util_test.dart
example/test/util_test.dart
+60
-0
lib/src/in_app_localhost_server.dart
lib/src/in_app_localhost_server.dart
+2
-2
No files found.
.idea/workspace.xml
View file @
7c5b1a1c
This diff is collapsed.
Click to expand it.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
View file @
7c5b1a1c
...
@@ -567,10 +567,17 @@ public class InAppWebViewClient extends WebViewClient {
...
@@ -567,10 +567,17 @@ public class InAppWebViewClient extends WebViewClient {
URI
uri
;
URI
uri
;
try
{
try
{
uri
=
new
URI
(
url
);
uri
=
new
URI
(
url
);
}
catch
(
URISyntaxException
e
)
{
}
catch
(
URISyntaxException
uriExpection
)
{
e
.
printStackTrace
();
String
[]
urlSplitted
=
url
.
split
(
":"
);
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
String
scheme
=
urlSplitted
[
0
];
return
null
;
try
{
URL
tempUrl
=
new
URL
(
url
.
replace
(
scheme
,
"https"
));
uri
=
new
URI
(
scheme
,
tempUrl
.
getUserInfo
(),
tempUrl
.
getHost
(),
tempUrl
.
getPort
(),
tempUrl
.
getPath
(),
tempUrl
.
getQuery
(),
tempUrl
.
getRef
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Log
.
d
(
LOG_TAG
,
e
.
getMessage
());
return
null
;
}
}
}
String
scheme
=
uri
.
getScheme
();
String
scheme
=
uri
.
getScheme
();
...
...
example/lib/main.dart
View file @
7c5b1a1c
...
@@ -25,9 +25,6 @@ class MyApp extends StatefulWidget {
...
@@ -25,9 +25,6 @@ class MyApp extends StatefulWidget {
}
}
class
_MyAppState
extends
State
<
MyApp
>
{
class
_MyAppState
extends
State
<
MyApp
>
{
InAppWebViewController
webView
;
String
url
=
""
;
double
progress
=
0
;
@override
@override
void
initState
()
{
void
initState
()
{
...
...
example/pubspec.yaml
View file @
7c5b1a1c
...
@@ -26,6 +26,7 @@ dependencies:
...
@@ -26,6 +26,7 @@ dependencies:
dev_dependencies
:
dev_dependencies
:
flutter_test
:
flutter_test
:
sdk
:
flutter
sdk
:
flutter
ansicolor
:
1.0.2
flutter_inappbrowser
:
flutter_inappbrowser
:
path
:
../
path
:
../
...
...
example/test/custom_widget_test.dart
0 → 100644
View file @
7c5b1a1c
import
'package:ansicolor/ansicolor.dart'
;
import
'package:flutter/widgets.dart'
;
class
WidgetTest
extends
StatefulWidget
{
final
String
name
;
WidgetTest
({
this
.
name
,
Key
key
}):
super
(
key:
key
)
{
AnsiPen
pen
=
new
AnsiPen
()..
white
()..
rgb
(
r:
1.0
,
g:
0.8
,
b:
0.2
);
print
(
"
\n
"
);
print
(
pen
(
"'"
+
this
.
name
+
"' test loading..."
));
print
(
"
\n
"
);
}
@override
State
<
StatefulWidget
>
createState
()
{
return
null
;
}
}
\ No newline at end of file
example/test/in_app_webview_initial_file_test.dart
0 → 100644
View file @
7c5b1a1c
import
'package:flutter/material.dart'
;
import
'package:flutter_inappbrowser/flutter_inappbrowser.dart'
;
import
'util_test.dart'
;
import
'custom_widget_test.dart'
;
class
InAppWebViewInitialFileTest
extends
WidgetTest
{
InAppWebViewInitialFileTest
():
super
(
name:
"InAppWebViewInitialFileTest"
);
@override
_InAppWebViewInitialFileTestState
createState
()
=>
new
_InAppWebViewInitialFileTestState
();
}
class
_InAppWebViewInitialFileTestState
extends
State
<
InAppWebViewInitialFileTest
>
{
InAppWebViewController
webView
;
String
initialUrl
=
"https://flutter.dev/"
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'InAppWebViewInitialFileTest'
),
),
body:
Container
(
child:
Column
(
children:
<
Widget
>[
Expanded
(
child:
Container
(
child:
InAppWebView
(
initialFile:
"assets/index.html"
,
initialHeaders:
{},
initialOptions:
InAppWebViewWidgetOptions
(),
onWebViewCreated:
(
InAppWebViewController
controller
)
{
webView
=
controller
;
},
onLoadStart:
(
InAppWebViewController
controller
,
String
url
)
{
},
onLoadStop:
(
InAppWebViewController
controller
,
String
url
)
{
customAssert
(
widget:
widget
,
name:
"initialFile"
,
value:
true
);
nextTest
(
context:
context
);
},
),
),
),
])
)
);
}
}
example/test/in_app_webview_initial_url_test.dart
0 → 100644
View file @
7c5b1a1c
import
'package:flutter/material.dart'
;
import
'package:flutter_inappbrowser/flutter_inappbrowser.dart'
;
import
'util_test.dart'
;
import
'custom_widget_test.dart'
;
class
InAppWebViewInitialUrlTest
extends
WidgetTest
{
InAppWebViewInitialUrlTest
():
super
(
name:
"InAppWebViewInitialUrlTest"
);
@override
_InAppWebViewInitialUrlTestState
createState
()
=>
new
_InAppWebViewInitialUrlTestState
();
}
class
_InAppWebViewInitialUrlTestState
extends
State
<
InAppWebViewInitialUrlTest
>
{
InAppWebViewController
webView
;
String
initialUrl
=
"https://flutter.dev/"
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'InAppWebViewInitialUrlTest'
),
),
body:
Container
(
child:
Column
(
children:
<
Widget
>[
Expanded
(
child:
Container
(
child:
InAppWebView
(
initialUrl:
initialUrl
,
initialHeaders:
{},
initialOptions:
InAppWebViewWidgetOptions
(),
onWebViewCreated:
(
InAppWebViewController
controller
)
{
webView
=
controller
;
},
onLoadStart:
(
InAppWebViewController
controller
,
String
url
)
{
},
onLoadStop:
(
InAppWebViewController
controller
,
String
url
)
{
customAssert
(
widget:
widget
,
name:
"initialUrl"
,
value:
url
==
initialUrl
);
nextTest
(
context:
context
);
},
),
),
),
])
)
);
}
}
example/test/in_app_webview_on_load_resource_test.dart
0 → 100644
View file @
7c5b1a1c
import
'package:flutter/material.dart'
;
import
'package:flutter_inappbrowser/flutter_inappbrowser.dart'
;
import
'util_test.dart'
;
import
'custom_widget_test.dart'
;
class
InAppWebViewOnLoadResourceTest
extends
WidgetTest
{
InAppWebViewOnLoadResourceTest
():
super
(
name:
"InAppWebViewOnLoadResourceTest"
);
@override
_InAppWebViewOnLoadResourceTestState
createState
()
=>
new
_InAppWebViewOnLoadResourceTestState
();
}
class
_InAppWebViewOnLoadResourceTestState
extends
State
<
InAppWebViewOnLoadResourceTest
>
{
InAppWebViewController
webView
;
List
<
String
>
resourceList
=
[
"http://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css"
,
"https://code.jquery.com/jquery-3.3.1.min.js"
,
"https://via.placeholder.com/100x50"
];
int
countResources
=
0
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'InAppWebViewOnLoadResourceTest'
),
),
body:
Container
(
child:
Column
(
children:
<
Widget
>[
Expanded
(
child:
Container
(
child:
InAppWebView
(
initialFile:
"assets/index.html"
,
initialHeaders:
{},
initialOptions:
InAppWebViewWidgetOptions
(
inAppWebViewOptions:
InAppWebViewOptions
(
clearCache:
true
,
useOnLoadResource:
true
)
),
onWebViewCreated:
(
InAppWebViewController
controller
)
{
webView
=
controller
;
},
onLoadStart:
(
InAppWebViewController
controller
,
String
url
)
{
},
onLoadStop:
(
InAppWebViewController
controller
,
String
url
)
{
},
onLoadResource:
(
InAppWebViewController
controller
,
LoadedResource
response
)
{
customAssert
(
widget:
widget
,
name:
"onLoadResource"
,
value:
resourceList
.
contains
(
response
.
url
));
countResources
++;
if
(
countResources
==
resourceList
.
length
)
{
nextTest
(
context:
context
);
}
}
),
),
),
])
)
);
}
}
example/test/main_test.dart
0 → 100644
View file @
7c5b1a1c
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'in_app_webview_initial_file_test.dart'
;
import
'in_app_webview_initial_url_test.dart'
;
import
'in_app_webview_on_load_resource_test.dart'
;
Future
main
(
)
async
{
runApp
(
new
MyApp
());
}
class
MyApp
extends
StatefulWidget
{
@override
_MyAppState
createState
()
=>
new
_MyAppState
();
}
class
_MyAppState
extends
State
<
MyApp
>
{
@override
void
initState
()
{
super
.
initState
();
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
'flutter_inappbrowser tests'
,
initialRoute:
'/'
,
routes:
{
'/'
:
(
context
)
=>
InAppWebViewInitialUrlTest
(),
'/InAppWebViewInitialFileTest'
:
(
context
)
=>
InAppWebViewInitialFileTest
(),
'/InAppWebViewOnLoadResourceTest'
:
(
context
)
=>
InAppWebViewOnLoadResourceTest
()
}
);
}
}
\ No newline at end of file
example/test/util_test.dart
0 → 100644
View file @
7c5b1a1c
import
'package:ansicolor/ansicolor.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'custom_widget_test.dart'
;
int
countTestPassed
=
0
;
int
countTestFailed
=
0
;
int
currentTest
=
0
;
List
<
String
>
testRoutes
=
[
'/'
,
'/InAppWebViewInitialFileTest'
,
'/InAppWebViewOnLoadResourceTest'
];
void
nextTest
(
{
@required
BuildContext
context
})
{
if
(
currentTest
+
1
<
testRoutes
.
length
)
{
currentTest
++;
String
nextRoute
=
testRoutes
[
currentTest
];
Navigator
.
pushReplacementNamed
(
context
,
nextRoute
);
}
else
{
AnsiPen
penError
=
new
AnsiPen
()..
white
()..
rgb
(
r:
1.0
,
g:
0.0
,
b:
0.0
);
AnsiPen
penSuccess
=
new
AnsiPen
()..
white
()..
rgb
(
r:
0.0
,
g:
1.0
,
b:
0.0
);
if
(
countTestFailed
>
0
)
print
(
"
\n
"
+
penError
(
"Total tests failed
$countTestFailed
."
)
+
"
\n
"
);
if
(
countTestPassed
>
0
)
print
(
"
\n
"
+
penSuccess
(
"Total tests passed
$countTestPassed
."
)
+
"
\n
"
);
}
}
bool
customAssert
(
{
WidgetTest
widget
,
String
name
,
@required
bool
value
})
{
try
{
assert
(
value
);
}
catch
(
e
,
stackTrace
)
{
String
message
=
"
${widget != null ? "'" + widget.name + "' - " : ""}
ERROR - Failed assertion: "
;
List
<
String
>
stakTraceSplitted
=
stackTrace
.
toString
().
split
(
"
\n
"
);
String
lineCallingAssert
=
stakTraceSplitted
[
3
].
trim
().
substring
(
2
).
trim
();
AnsiPen
penError
=
new
AnsiPen
()..
white
()..
rgb
(
r:
1.0
,
g:
0.0
,
b:
0.0
);
print
(
"
\n
"
+
penError
(
message
+
lineCallingAssert
)
+
"
\n
"
);
countTestFailed
++;
return
false
;
}
countTestPassed
++;
try
{
throw
Exception
();
}
on
Exception
catch
(
e
,
stackTrace
)
{
String
message
=
"
${widget != null ? "'" + widget.name + "' - " : ""}
Test "
;
message
+=
(
name
!=
null
)
?
"'
$name
' "
:
""
;
message
+=
"passed!"
;
List
<
String
>
stakTraceSplitted
=
stackTrace
.
toString
().
split
(
"
\n
"
);
String
lineCallingAssert
=
stakTraceSplitted
[
1
].
trim
().
substring
(
2
).
trim
();
message
+=
"
$lineCallingAssert
"
;
AnsiPen
pen
=
new
AnsiPen
()..
white
()..
rgb
(
r:
1.0
,
g:
0.8
,
b:
0.2
);
print
(
"
\n
"
+
pen
(
message
)
+
"
\n
"
);
}
return
true
;
}
\ No newline at end of file
lib/src/in_app_localhost_server.dart
View file @
7c5b1a1c
...
@@ -45,7 +45,7 @@ class InAppLocalhostServer {
...
@@ -45,7 +45,7 @@ class InAppLocalhostServer {
var
body
=
List
<
int
>();
var
body
=
List
<
int
>();
var
path
=
request
.
requestedUri
.
path
;
var
path
=
request
.
requestedUri
.
path
;
path
=
(
path
.
startsWith
(
'/'
))
?
path
.
substring
(
1
)
:
path
;
path
=
(
path
.
startsWith
(
'/'
))
?
path
.
substring
(
1
)
:
path
;
path
+=
(
path
.
endsWith
(
'/'
))
?
'
t-r
ex.html'
:
''
;
path
+=
(
path
.
endsWith
(
'/'
))
?
'
ind
ex.html'
:
''
;
try
{
try
{
body
=
(
await
rootBundle
.
load
(
path
))
body
=
(
await
rootBundle
.
load
(
path
))
...
@@ -85,4 +85,4 @@ class InAppLocalhostServer {
...
@@ -85,4 +85,4 @@ class InAppLocalhostServer {
}
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment