Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
- 'apps/levantamiento/**'
- 'scripts/grafo_campus.py'
- 'scripts/test_grafo_campus.py'
- 'scripts/preparar_modelo3d.py'
- 'scripts/test_modelo3d.py'
- '.github/workflows/mobile.yml'
pull_request:
paths:
Expand All @@ -22,6 +24,8 @@ on:
- 'apps/levantamiento/**'
- 'scripts/grafo_campus.py'
- 'scripts/test_grafo_campus.py'
- 'scripts/preparar_modelo3d.py'
- 'scripts/test_modelo3d.py'
- '.github/workflows/mobile.yml'

# El token de GitHub de estos jobs solo necesita leer el código.
Expand All @@ -43,7 +47,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- run: python -I -m unittest discover -s scripts -p test_grafo_campus.py -v
- run: python -I -m unittest discover -s scripts -p 'test_*.py' -v

modulo:
name: Modulo (formato, codigo generado y analisis)
Expand Down Expand Up @@ -164,6 +168,8 @@ jobs:
cache: true

- run: flutter pub get
- name: Preparar maqueta 3D del campus
run: python ../../scripts/preparar_modelo3d.py
- run: flutter build apk --debug

- uses: actions/upload-artifact@v4
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ apps/mobile/android/app/src/assets/mapa_campus.webp
# Al repo solo va el grafo que sale de ellos.
levantamiento-*.json
recorridos*.geojson

# Maqueta institucional de ElMapita: scripts/preparar_modelo3d.py la descarga
# y prepara; se empaqueta en el APK, sin versionar el binario.
/packages/tour_virtual/assets/mapa3d/*.glb
112 changes: 112 additions & 0 deletions apps/levantamiento/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
android_intent_plus:
dependency: transitive
description:
name: android_intent_plus
sha256: "4d4bbd619d698cbee3c400ba89246ecb0f525146b0ae05389f62ede47abd5bec"
url: "https://pub.dev"
source: hosted
version: "6.1.0"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -549,6 +557,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
model_viewer_plus:
dependency: transitive
description:
name: model_viewer_plus
sha256: c5bfcd296a28246cceec821b0e7da268690e40baa99a3fa0f09d7a3227eb967d
url: "https://pub.dev"
source: hosted
version: "1.10.0"
objective_c:
dependency: transitive
description:
Expand Down Expand Up @@ -897,6 +913,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
url_launcher:
dependency: transitive
description:
name: url_launcher
sha256: e8cc955c97e06df9879140a1fe301f3d493f01b7c62dec7f46834be31d7e9fda
url: "https://pub.dev"
source: hosted
version: "6.3.3"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
sha256: "17bc677f0b301615530dd1d67e0a9828cafa2d0b6b6eae4cd3679b7eac4a273c"
url: "https://pub.dev"
source: hosted
version: "6.3.30"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: "8faa1aab294f1ab4040b43660c887b0418d5fa4f0cffef76a484e6aa1092eb4a"
url: "https://pub.dev"
source: hosted
version: "6.4.2"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: "10f86fef4c2c43563fa6c211ff9cf757adf4d3ab762c56bd430664a947d70cd0"
url: "https://pub.dev"
source: hosted
version: "3.2.3"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
sha256: "5e835a3b869c2d70325349c81c5a45c28e20791265b67b2669da6b08c5cd5201"
url: "https://pub.dev"
source: hosted
version: "3.2.6"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34"
url: "https://pub.dev"
source: hosted
version: "2.4.3"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "6c5ad3f22cd4c38e089b81963b3cd7bb83b111b2df5dce008bb066162f42e429"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
uuid:
dependency: transitive
description:
Expand Down Expand Up @@ -985,6 +1065,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.1"
webview_flutter:
dependency: transitive
description:
name: webview_flutter
sha256: c3e4fe614b1c814950ad07186007eff2f2e5dd2935eba7b9a9a1af8e5885f1ba
url: "https://pub.dev"
source: hosted
version: "4.13.0"
webview_flutter_android:
dependency: transitive
description:
name: webview_flutter_android
sha256: ad5182eff9a550925330cb9f0cb038eddfdd5712aba8b77aa0f0400e50f6e688
url: "https://pub.dev"
source: hosted
version: "4.12.0"
webview_flutter_platform_interface:
dependency: transitive
description:
name: webview_flutter_platform_interface
sha256: "1221c1b12f5278791042f2ec2841743784cf25c5a644e23d6680e5d718824f04"
url: "https://pub.dev"
source: hosted
version: "2.15.1"
webview_flutter_wkwebview:
dependency: transitive
description:
name: webview_flutter_wkwebview
sha256: "82648217f537573e1ca9ae9952d3eacedca6ab5aee69dc84445fc763766dcea2"
url: "https://pub.dev"
source: hosted
version: "3.25.1"
win32:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ GeneratedPluginRegistrant.java
key.properties
**/*.keystore
**/*.jks
.kotlin/
1 change: 1 addition & 0 deletions apps/mobile/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
android:label="@string/app_name"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="false">
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- El visor 3D sirve el GLB empaquetado en el propio teléfono. Solo
loopback admite HTTP; la API y los medios externos siguen exigiendo HTTPS. -->
<network-security-config>
<base-config cleartextTrafficPermitted="false" />
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">127.0.0.1</domain>
<domain includeSubdomains="false">localhost</domain>
</domain-config>
</network-security-config>
146 changes: 146 additions & 0 deletions apps/mobile/integration_test/mapa_3d_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tour_virtual/app_tour.dart';
import 'package:tour_virtual/configuracion_tour.dart';
import 'package:tour_virtual/datos/preferencias.dart';
import 'package:tour_virtual/l10n/textos.dart';
import 'package:tour_virtual/nucleo/tema.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('modelo local, controles, ficha y regreso al plano', (
tester,
) async {
// Preferencias en memoria: esta comprobación no borra ni modifica las
// preferencias y las visitas guardadas por la persona en su teléfono.
SharedPreferences.setMockInitialValues({});
await tester.pumpWidget(_aplicacion(1));
await _esperar(
tester,
() => find.byIcon(Icons.map_rounded).evaluate().isNotEmpty,
);
await tester.tap(find.byIcon(Icons.map_rounded));
await _pausa(tester);
await binding.convertFlutterSurfaceToImage();
await tester.pump();
await binding.takeScreenshot('phone-mapa-2d');

await tester.tap(find.byTooltip('Ver mapa en 3D'));
await _esperar(
tester,
() => find.byTooltip('Girar a la derecha').evaluate().isNotEmpty,
);
await _pausa(tester);
final web = tester
.widget<WebViewWidget>(find.byType(WebViewWidget))
.platform
.params
.controller;
expect(
await web.runJavaScriptReturningResult(
"document.querySelector('model-viewer').loaded",
),
true,
);
final pines = await web.runJavaScriptReturningResult(
"document.querySelectorAll('[data-tour-poi]').length",
);
expect(_numero(pines), greaterThanOrEqualTo(5));
await binding.takeScreenshot('phone-mapa-3d');

final radio = await web.runJavaScriptReturningResult(
"document.querySelector('model-viewer').getCameraOrbit().radius",
);
await tester.tap(find.byTooltip('Acercar'));
await _pausa(tester);
final cerca = await web.runJavaScriptReturningResult(
"document.querySelector('model-viewer').getCameraOrbit().radius",
);
expect(_numero(cerca), lessThan(_numero(radio)));
await tester.tap(find.byTooltip('Girar a la derecha'));
await _pausa(tester);
await binding.takeScreenshot('phone-mapa-3d-giro');

await web.runJavaScript(
"document.querySelector('[data-tour-poi=\"1\"]').click()",
);
await _esperar(
tester,
() => find.byType(BottomSheet).evaluate().isNotEmpty,
);
await _pausa(tester);
await binding.takeScreenshot('phone-mapa-3d-ficha');
Navigator.of(tester.element(find.byType(BottomSheet))).pop();
await _pausa(tester);
await tester.tap(find.byTooltip('Volver al mapa 2D'));
await _pausa(tester);
expect(find.byTooltip('Ver mapa en 3D'), findsOneWidget);
expect(find.byType(InteractiveViewer), findsOneWidget);
await binding.takeScreenshot('phone-mapa-2d-regreso');

await tester.tap(find.byTooltip('Ver mapa en 3D'));
await _pausa(tester);
await tester.pumpWidget(_aplicacion(2));
await _pausa(tester);
await binding.takeScreenshot('phone-mapa-3d-texto-grande');
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump(const Duration(seconds: 1));
});
}

double _numero(Object valor) =>
valor is num ? valor.toDouble() : double.parse('$valor');

Future<void> _pausa(WidgetTester tester) async {
await tester.pump(const Duration(seconds: 2));
await tester.pump();
}

Future<void> _esperar(WidgetTester tester, bool Function() condicion) async {
final limite = DateTime.now().add(const Duration(seconds: 40));
while (!condicion() && DateTime.now().isBefore(limite)) {
await tester.pump(const Duration(milliseconds: 150));
}
expect(
condicion(),
isTrue,
reason: 'La pantalla no llegó al estado esperado',
);
}

Widget _aplicacion(double escala) => ProviderScope(
overrides: [
configuracionTourProvider.overrideWithValue(
const ConfiguracionTour(fuente: ContenidoLocal(medios: 'empaquetados')),
),
preferenciasInicialesProvider.overrideWithValue(
const Preferencias(idioma: Locale('es'), analitica: false),
),
],
child: _AppCaptura(escala: escala),
);

class _AppCaptura extends StatelessWidget {
const _AppCaptura({required this.escala});
final double escala;

@override
Widget build(BuildContext context) => MaterialApp(
locale: const Locale('es'),
supportedLocales: Textos.supportedLocales,
localizationsDelegates: Textos.localizationsDelegates,
theme: temaUtb(altoContraste: false),
builder: (context, child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(escala)),
child: child!,
),
home: const HomeScreen(),
);
}
5 changes: 5 additions & 0 deletions apps/mobile/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Para guiarte a pie por el campus de la UTB. Tu ubicación no sale del teléfono ni se guarda.</string>
<key>NSCameraUsageDescription</key>
Expand Down
4 changes: 4 additions & 0 deletions apps/mobile/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#include "generated_plugin_registrant.h"

#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}
1 change: 1 addition & 0 deletions apps/mobile/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_linux
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down
Loading
Loading