|
| 1 | +# π§ͺ WebView Testing Framework |
| 2 | + |
| 3 | +This framework provides a standardized way to test different WebView packages for Unity integration with Immutable Passport. |
| 4 | + |
| 5 | +## π― Purpose |
| 6 | + |
| 7 | +- **Compare WebView packages** (Volt Unity Web Browser, Alacrity, UWebView2, ZenFulcrum, Vuplex 3D WebView) |
| 8 | +- **Test login page rendering** with actual Passport authentication |
| 9 | +- **Evaluate message passing** between JavaScript and Unity |
| 10 | +- **Measure performance** (FPS, memory usage, rendering quality) |
| 11 | +- **Validate SDK integration** for distribution |
| 12 | + |
| 13 | +## π Structure |
| 14 | + |
| 15 | +``` |
| 16 | +WebViewTesting/ |
| 17 | +βββ WebViewTestManager.cs # Main test controller |
| 18 | +βββ IWebViewAdapter.cs # Common interface for all WebView packages |
| 19 | +βββ AlacrityWebViewAdapter.cs # Alacrity WebView implementation |
| 20 | +βββ UWebView2Adapter.cs # UWebView2 implementation |
| 21 | +βββ ZenFulcrumWebViewAdapter.cs # ZenFulcrum implementation |
| 22 | +βββ Vuplex3DWebViewAdapter.cs # Vuplex 3D WebView implementation |
| 23 | +βββ WebViewTestSceneSetup.cs # Editor utility to create test scene |
| 24 | +βββ README.md # This file |
| 25 | +``` |
| 26 | + |
| 27 | +## π Quick Start |
| 28 | + |
| 29 | +### 1. Create Test Scene |
| 30 | + |
| 31 | +```csharp |
| 32 | +// In Unity Editor: |
| 33 | +Immutable β WebView Testing β Create WebView Test Scene |
| 34 | +``` |
| 35 | + |
| 36 | +### 2. Import WebView Package |
| 37 | + |
| 38 | +Download and import one of the WebView packages: |
| 39 | + |
| 40 | +- **Volt Unity Web Browser (UWB)**: `https://projects.voltstro.dev/UnityWebBrowser/latest/` β **RECOMMENDED** (MIT License, Multi-Platform) |
| 41 | +- **Alacrity**: `https://alacrity.kevinbedi.com/` |
| 42 | +- **UWebView2**: `https://uwebview.com/` |
| 43 | +- **ZenFulcrum**: `https://zenfulcrum.com/browser` |
| 44 | +- **Vuplex 3D WebView**: `https://store.vuplex.com/webview/windows-mac` |
| 45 | + |
| 46 | +### 3. Update Adapter Implementation |
| 47 | + |
| 48 | +Replace the template code in the corresponding adapter (e.g., `AlacrityWebViewAdapter.cs`) with actual WebView API calls. |
| 49 | + |
| 50 | +### 4. Run Tests |
| 51 | + |
| 52 | +1. Open the WebView Test scene |
| 53 | +2. |
| 54 | +3. Select the WebView package in the dropdown |
| 55 | +4. Click "Test Login Page" to test with `https://auth.immutable.com` |
| 56 | +5. Click "Test Messaging" to test JavaScript β Unity communication |
| 57 | + |
| 58 | +## π§ͺ Test Scenarios |
| 59 | + |
| 60 | +### Login Page Test |
| 61 | + |
| 62 | +- β
**Load Passport login page** (`https://auth.immutable.com`) |
| 63 | +- β
**Render CSS3 features** (rounded corners, gradients, fonts) |
| 64 | +- β
**Interactive elements** (buttons, forms, dropdowns) |
| 65 | +- β
**OAuth flow handling** (redirects, callbacks) |
| 66 | +- β
**Performance monitoring** (FPS, memory usage) |
| 67 | + |
| 68 | +### Message Passing Test |
| 69 | + |
| 70 | +- β
**Unity β JavaScript** communication |
| 71 | +- β
**JavaScript β Unity** communication |
| 72 | +- β
**OAuth callback simulation** |
| 73 | +- β
**Performance data exchange** |
| 74 | +- β
**Error handling** |
| 75 | + |
| 76 | +## π Evaluation Criteria |
| 77 | + |
| 78 | +Rate each WebView package (1-5 stars): |
| 79 | + |
| 80 | +| Criteria | Weight | Description | |
| 81 | +|----------|--------|-------------| |
| 82 | +| **Rendering Quality** | High | CSS3 support, font clarity, animations | |
| 83 | +| **Performance** | High | FPS, memory usage, startup time | |
| 84 | +| **Input Handling** | Medium | Mouse, keyboard responsiveness | |
| 85 | +| **Message Passing** | High | JavaScript β Unity communication | |
| 86 | +| **Setup Complexity** | Medium | Import β working in minutes | |
| 87 | +| **Documentation** | Low | Examples, API docs quality | |
| 88 | +| **Licensing Cost** | High | SDK distribution feasibility | |
| 89 | +| **Platform Support** | Medium | Windows, macOS, Linux | |
| 90 | + |
| 91 | +## π§ Implementation Guide |
| 92 | + |
| 93 | +### Adding a New WebView Package |
| 94 | + |
| 95 | +1. **Create Adapter Class**: |
| 96 | + |
| 97 | +```csharp |
| 98 | +public class MyWebViewAdapter : IWebViewAdapter |
| 99 | +{ |
| 100 | + // Implement all interface methods |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +1. **Update WebViewTestManager**: |
| 105 | + |
| 106 | +```csharp |
| 107 | +// Add to WebViewPackage enum |
| 108 | +public enum WebViewPackage |
| 109 | +{ |
| 110 | + MyWebView // Add here |
| 111 | +} |
| 112 | + |
| 113 | +// Add to CreateWebViewAdapter method |
| 114 | +case WebViewPackage.MyWebView: |
| 115 | + return new MyWebViewAdapter(); |
| 116 | +``` |
| 117 | + |
| 118 | +1. **Test Implementation**: |
| 119 | + |
| 120 | +- Run login page test |
| 121 | +- Verify message passing |
| 122 | +- Check performance metrics |
| 123 | + |
| 124 | +### Message Passing Implementation |
| 125 | + |
| 126 | +**JavaScript β Unity**: |
| 127 | + |
| 128 | +```javascript |
| 129 | +// In WebView |
| 130 | +window.unityInstance.SendMessage('WebViewTestManager', 'OnTestMessage', 'Hello Unity!'); |
| 131 | +``` |
| 132 | + |
| 133 | +**Unity β JavaScript**: |
| 134 | + |
| 135 | +```csharp |
| 136 | +// In Unity |
| 137 | +webView.ExecuteJavaScript("window.receiveUnityMessage('Hello WebView!');"); |
| 138 | +``` |
| 139 | + |
| 140 | +## π Test Results Template |
| 141 | + |
| 142 | +```markdown |
| 143 | +## WebView Package: [Package Name] |
| 144 | + |
| 145 | +### Setup |
| 146 | +- **Import Time**: X minutes |
| 147 | +- **Complexity**: Easy/Medium/Hard |
| 148 | +- **Dependencies**: List any required dependencies |
| 149 | + |
| 150 | +### Login Page Test |
| 151 | +- **Rendering Quality**: βββββ (5/5) |
| 152 | +- **Load Time**: X seconds |
| 153 | +- **Interactive Elements**: Working/Broken |
| 154 | +- **CSS3 Support**: Full/Partial/None |
| 155 | + |
| 156 | +### Performance |
| 157 | +- **Average FPS**: X fps |
| 158 | +- **Memory Usage**: X MB |
| 159 | +- **Startup Time**: X seconds |
| 160 | + |
| 161 | +### Message Passing |
| 162 | +- **Unity β JS**: Working/Broken |
| 163 | +- **JS β Unity**: Working/Broken |
| 164 | +- **OAuth Simulation**: Working/Broken |
| 165 | + |
| 166 | +### Licensing |
| 167 | +- **Cost**: $X or Free |
| 168 | +- **SDK Distribution**: Allowed/Restricted |
| 169 | +- **Commercial Use**: Allowed/Restricted |
| 170 | + |
| 171 | +### Overall Rating: βββββ (X/5) |
| 172 | +**Recommendation**: Use/Don't Use for SDK |
| 173 | +**Notes**: Additional observations... |
| 174 | +``` |
| 175 | + |
| 176 | +## π Test Resources |
| 177 | + |
| 178 | +- **Login Page**: `https://auth.immutable.com` |
| 179 | +- **Message Test Page**: `StreamingAssets/test-message-page.html` |
| 180 | +- **OAuth Callback**: `immutablerunner://callback?code=test&state=test` |
| 181 | + |
| 182 | +## π― Success Criteria |
| 183 | + |
| 184 | +A WebView package is suitable for SDK distribution if: |
| 185 | + |
| 186 | +1. β
**Renders login page correctly** (all elements visible and interactive) |
| 187 | +2. β
**Maintains 30+ FPS** during normal operation |
| 188 | +3. β
**Supports JavaScript β Unity** message passing |
| 189 | +4. β
**Licensing allows SDK distribution** (free or reasonable cost) |
| 190 | +5. β
**Easy integration** (< 1 hour setup for developers) |
| 191 | +6. β
**Handles OAuth callbacks** properly |
| 192 | + |
| 193 | +## π¨ Known Issues |
| 194 | + |
| 195 | +- **Template adapters** need actual WebView API implementation |
| 196 | +- **Message passing** methods vary between packages |
| 197 | +- **Performance metrics** may need package-specific implementation |
| 198 | +- **IL2CPP compatibility** should be tested for each package |
| 199 | + |
| 200 | +## π Support |
| 201 | + |
| 202 | +For questions about this testing framework: |
| 203 | + |
| 204 | +1. Check the adapter implementation for your WebView package |
| 205 | +2. Review the test HTML page for message passing examples |
| 206 | +3. Consult the WebView package documentation |
| 207 | +4. Test with the actual Passport login page |
| 208 | + |
| 209 | +--- |
| 210 | + |
| 211 | +**Happy Testing!** π§ͺβ¨ |
0 commit comments