Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6542700
:recycle: refactor: quantidade de If reduzida
andreza-vilar Mar 16, 2025
bcdc20e
:recycle: refactor: add default case to touch event switch
andreza-vilar Mar 16, 2025
64d6d0b
:recycle: refactor: fixing tests
Mar 19, 2025
e6b2536
Refactor: fix null reference issues to prevent potential NullPointerE…
buritizinhw Mar 20, 2025
7bd7140
Merge pull request #2 from Engenharia-de-Software-Grupo-1/Andreza
andreza-vilar Mar 21, 2025
fe72ef5
Merge pull request #3 from Engenharia-de-Software-Grupo-1/Rayanne
andreza-vilar Mar 21, 2025
e4f2baf
Merge pull request #4 from Engenharia-de-Software-Grupo-1/Livia
andreza-vilar Mar 21, 2025
d9187d9
Refactor: quantidade de condicoes reduzidas
cicerohenryque Mar 22, 2025
07061b6
test: creating new tests with the tool Qodo
KaykyFidelis Mar 23, 2025
33bac11
Merge pull request #5 from Engenharia-de-Software-Grupo-1/generated-t…
KaykyFidelis Mar 23, 2025
3faadfc
refatora interfaces em classes
Vinicius-TML Mar 23, 2025
f104361
finaliza refatoração de interfaces em classes
Vinicius-TML Mar 24, 2025
7c6931b
finaliza das refatorações
Vinicius-TML Mar 23, 2025
61c0ccd
refatora interfaces restantes
Vinicius-TML Mar 27, 2025
7ce13cc
test: adicionando mais tests para evolução do coverage.
KaykyFidelis Mar 27, 2025
5b19d02
fix: consertando erro de versionamento causado por outro integrante
KaykyFidelis Mar 27, 2025
96f1785
fix: removendo o qodo
KaykyFidelis Mar 27, 2025
8c3a247
Merge pull request #8 from Engenharia-de-Software-Grupo-1/generated-t…
KaykyFidelis Mar 27, 2025
95dcafb
Merge pull request #7 from Engenharia-de-Software-Grupo-1/Vinicius
KaykyFidelis Mar 27, 2025
eb307d2
Merge pull request #9 from Engenharia-de-Software-Grupo-1/cicerohpr
KaykyFidelis Mar 27, 2025
c0fbbb1
Merge pull request #6 from Engenharia-de-Software-Grupo-1/KaikyCodeSm…
KaykyFidelis Mar 27, 2025
ea28f7f
Att default case
cicerohenryque Mar 29, 2025
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
2 changes: 1 addition & 1 deletion omniNotes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ dependencies {
implementation 'ch.acra:acra-http:5.11.2'
implementation 'ch.acra:acra-toast:5.11.2'
implementation 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'
implementation 'com.github.vikramkakkar:SublimePicker:8f573b1cfd'
implementation 'com.github.vikramkakkar:SublimePicker:861620a11d'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'com.android.support:multidex:2.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package it.feio.android.omninotes.utils;
package it.feio.android.omninotes.utils;


public interface Constants extends ConstantsBase {

String TAG = "Omni Notes Alpha";
String EXTERNAL_STORAGE_FOLDER = "Omni Notes Alpha";
String PACKAGE = "it.feio.android.omninotes.alpha";

String CHANNEL_BACKUPS_ID = PACKAGE + ".backups";
String CHANNEL_REMINDERS_ID = PACKAGE + ".reminders";
String CHANNEL_PINNED_ID = PACKAGE + ".pinned";

}
public final class Constants extends ConstantsBase {

public static final String TAG = "Omni Notes Alpha";
public static final String EXTERNAL_STORAGE_FOLDER = "Omni Notes Alpha";
public static final String PACKAGE = "it.feio.android.omninotes.alpha";

public static final String CHANNEL_BACKUPS_ID = PACKAGE + ".backups";
public static final String CHANNEL_REMINDERS_ID = PACKAGE + ".reminders";
public static final String CHANNEL_PINNED_ID = PACKAGE + ".pinned";

private Constants() {
throw new AssertionError("Cannot be instantiated");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package it.feio.android.omninotes.exceptions;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;

import it.feio.android.omninotes.exceptions.unchecked.ExternalDirectoryCreationException;
import it.feio.android.omninotes.exceptions.checked.UnhandledIntentException;

import static org.junit.Assert.assertThrows;

@RunWith(AndroidJUnit4.class)
public class ExceptionsInstrumentationTest {

@Test
public void testGenericException() {
assertThrows(GenericException.class, () -> {
throw new GenericException("Test GenericException");
});
}

@Test
public void testDatabaseException() {
assertThrows(DatabaseException.class, () -> {
throw new DatabaseException("Test DatabaseException", new Exception("Cause"));
});
}

@Test
public void testBackupException() {
assertThrows(BackupException.class, () -> {
throw new BackupException("Test BackupException", new Exception("Cause"));
});
}

@Test
public void testNotesLoadingException() {
assertThrows(NotesLoadingException.class, () -> {
throw new NotesLoadingException("Test NotesLoadingException", new Exception("Cause"));
});
}

@Test
public void testUnhandledIntentException() {
assertThrows(UnhandledIntentException.class, () -> {
throw new UnhandledIntentException();
});
}

@Test
public void testExternalDirectoryCreationException() {
assertThrows(ExternalDirectoryCreationException.class, () -> {
throw new ExternalDirectoryCreationException("Test ExternalDirectoryCreationException");
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package it.feio.android.omninotes.factory;

import android.net.Uri;
import android.provider.MediaStore;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

@RunWith(AndroidJUnit4.class)
public class MediaStoreFactoryInstrumentationTest {

private MediaStoreFactory mediaStoreFactory;

@Before
public void setUp() {
mediaStoreFactory = new MediaStoreFactory();
}

@Test
public void testCreateURI_image() {
Uri expectedUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
Uri actualUri = mediaStoreFactory.createURI("image");
assertEquals("URI should match for image type", expectedUri, actualUri);
}

@Test
public void testCreateURI_video() {
Uri expectedUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
Uri actualUri = mediaStoreFactory.createURI("video");
assertEquals("URI should match for video type", expectedUri, actualUri);
}

@Test
public void testCreateURI_audio() {
Uri expectedUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Uri actualUri = mediaStoreFactory.createURI("audio");
assertEquals("URI should match for audio type", expectedUri, actualUri);
}

@Test
public void testCreateURI_invalidType() {
Uri actualUri = mediaStoreFactory.createURI("invalid");
assertNull("URI should be null for invalid type", actualUri);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package it.feio.android.omninotes.helpers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import android.net.Uri;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import it.feio.android.omninotes.models.Attachment;
import java.io.File;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class AttachmentsHelperTest {

private Attachment testAttachment;

@Before
public void setUp() {
Uri uri = Uri.fromFile(new File("/path/to/test/file"));
testAttachment = new Attachment(uri, "image/jpeg");
testAttachment.setSize(1024); // Set size to 1KB for testing
}

@Test
public void testGetSize() {
String expectedSize = "1 KB";
String actualSize = AttachmentsHelper.getSize(testAttachment);
assertEquals("The size should be 1 KB", expectedSize, actualSize);
}

@Test
public void testGetSizeWithZeroSize() {
testAttachment.setSize(0); // Simulate a zero size
String actualSize = AttachmentsHelper.getSize(testAttachment);
assertTrue("The size should be greater than 0", actualSize.contains("bytes"));
}

@Test
public void testTypeOf() {
assertTrue("The attachment should be of type image/jpeg",
AttachmentsHelper.typeOf(testAttachment, "image/jpeg"));
}

@Test
public void testTypeOfWithMultipleMimeTypes() {
assertTrue("The attachment should be of type image/jpeg or image/png",
AttachmentsHelper.typeOf(testAttachment, "image/jpeg", "image/png"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package it.feio.android.omninotes.helpers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import it.feio.android.omninotes.models.Attachment;
import it.feio.android.omninotes.models.Note;
import it.feio.android.omninotes.models.StatsSingleNote;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class NotesHelperInstrumentationTest {

private Context context;

@Before
public void setUp() {
context = ApplicationProvider.getApplicationContext();
}

@Test
public void testHaveSameId() {
Note note1 = new Note();
note1.set_id(1L);
Note note2 = new Note();
note2.set_id(1L);
Note note3 = new Note();
note3.set_id(2L);

assertTrue(NotesHelper.haveSameId(note1, note2));
assertFalse(NotesHelper.haveSameId(note1, note3));
}

@Test
public void testMergeNotes() {
Note note1 = new Note();
note1.setTitle("Title 1");
note1.setContent("Content 1");

Note note2 = new Note();
note2.setTitle("Title 2");
note2.setContent("Content 2");

List<Note> notes = Arrays.asList(note1, note2);
Note mergedNote = NotesHelper.mergeNotes(notes, false);

assertNotNull(mergedNote);
assertEquals("Title 1", mergedNote.getTitle());
assertTrue(mergedNote.getContent().contains("Content 1"));
assertTrue(mergedNote.getContent().contains("Content 2"));
}

@Test
public void testGetNoteInfo() {
Note note = new Note();
note.setContent("This is a test note with some words.");

StatsSingleNote info = NotesHelper.getNoteInfo(note);

assertNotNull(info);
assertEquals(8, info.getWords());
assertEquals(29, info.getChars());
}

@Test
public void testAddAttachments() {
Note note = new Note();
note.setAttachmentsList(new ArrayList<>());

ArrayList<Attachment> attachments = new ArrayList<>();
NotesHelper.addAttachments(false, note, attachments);

assertEquals(0, attachments.size());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package it.feio.android.omninotes.helpers.count;

import static org.junit.Assert.assertEquals;
import it.feio.android.omninotes.models.Note;
import it.feio.android.omninotes.testutils.BaseAndroidTestCase;

import org.junit.Test;

public class DefaultWordCounterIntegrationTest extends BaseAndroidTestCase {

private final String CHECKED_SYM = it.feio.android.checklistview.interfaces.Constants.CHECKED_SYM;
private final String UNCHECKED_SYM = it.feio.android.checklistview.interfaces.Constants.UNCHECKED_SYM;

@Test
public void testCountWordsWithSimpleText() {
Note note = new Note();
note.set_id(1L);
note.setTitle("Hello World");
note.setContent("This is a test note.");
assertEquals(7, new DefaultWordCounter().countWords(note));
}

@Test
public void testCountWordsWithChecklist() {
String content = CHECKED_SYM + "Task 1\n" + UNCHECKED_SYM + "Task 2";
Note note = new Note();
note.set_id(1L);
note.setTitle("Checklist");
note.setContent(content);
note.setChecklist(true);
assertEquals(3, new DefaultWordCounter().countWords(note));
}

@Test
public void testCountCharsWithSimpleText() {
Note note = new Note();
note.set_id(1L);
note.setTitle("Hello World");
note.setContent("This is a test note.");
assertEquals(26, new DefaultWordCounter().countChars(note));
}

@Test
public void testCountCharsWithChecklist() {
String content = CHECKED_SYM + "Task 1\n" + UNCHECKED_SYM + "Task 2";
Note note = new Note();
note.set_id(1L);
note.setTitle("Checklist");
note.setContent(content);
note.setChecklist(true);
assertEquals(19, new DefaultWordCounter().countChars(note));
}
}
Loading