Загрузка данных


41
public class ExampleUnitTest {
@Test
public void testAddition() {
assertEquals(4, 2 + 2);
}
@Test
public void testUrlString() {
String url = "https://jsonplaceholder.typicode.com/todos/1";
assertTrue(url.startsWith("https"));
assertTrue(url.contains("jsonplaceholder"));
}
@Test
public void testBluetoothAddressPlaceholder() {
String macAddress = "AA:BB:CC:11:22:33";
assertTrue(macAddress.matches("^([0-9A-F]{2}:){5}[0-9A-F]{2}$"));
}
}
________________________
42
@RunWith(AndroidJUnit4.class)public class ExampleInstrumentedTest {
@Rule
public ActivityScenarioRule<MainActivity> activityRule = new ActivityScenarioRule<>(MainActivity.class);
@Test
public void testButtonClick_ChangesText() {
Espresso.onView(ViewMatchers.withId(R.id.btnFetchData))
.perform(ViewActions.click());
Espresso.onView(ViewMatchers.withId(R.id.tvNetResult))
.check(ViewAssertions.matches(ViewMatchers.withText("Загрузка...")));
}
}
____________________
43
private void makeCall() {
String num = etPhone.getText().toString();
if (!num.isEmpty()) startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + num)));
}
private void sendSms() {
String num = etPhone.getText().toString();
String msg = etSmsMessage.getText().toString();
if (!num.isEmpty() && !msg.isEmpty()) {
SmsManager.getDefault().sendTextMessage(num, null, msg, null, null);
Toast.makeText(this, "Отправлено", Toast.LENGTH_SHORT).show();
}
}
___________________________
@Test
public void testSmsInputs() {
String testPhone = "123456";String testMsg = "Hello Test";
Espresso.onView(ViewMatchers.withId(R.id.etPhone))
.perform(ViewActions.typeText(testPhone), ViewActions.closeSoftKeyboard());
Espresso.onView(ViewMatchers.withId(R.id.etSmsMessage))
.perform(ViewActions.typeText(testMsg), ViewActions.closeSoftKeyboard());
Espresso.onView(ViewMatchers.withId(R.id.etPhone))
.check(ViewAssertions.matches(ViewMatchers.withText(testPhone)));
}
_____________________________
44
public class ExampleUnitTest {
@Test
public void testDataProcessing_ValidData() {
String input = "{\"id\": 1, \"title\": \"test\"}";
assertTrue(input.contains("id"));
assertTrue(input.length() > 0);
}
@Test
public void testDataProcessing_InvalidData() {
String input = "";
assertEquals(0, input.length());
}
@Test
public void testDataProcessing_BoundaryCase() {
StringBuilder sb = new StringBuilder();
for(int i=0; i<1000; i++) sb.append("a");
String longText = sb.toString();
assertEquals(1000, longText.length());
}
}
___________________________
45
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/build
/captures
.externalNativeBuild
.cxx
/google-services.json
_____________________________
Kotlin
# 1. Инициализация репозитория
git init

# 2. Добавление всех файлов в индекс
git add .

# 3. Первый коммит (фиксация)
git commit -m "Initial commit: Project structure and Labs 32-44"

# 4. Проверка статуса
git status

# 5. Пример внесения изменений и второго коммита
git add .
git commit -m "Update: Added Lab 45 documentation"