about summary refs log blame commit diff stats
path: root/tests/unittests/log/stub_log.c
blob: dfbec2bd4f2a59573c079f1411b530bd514c59ca (plain) (tree)
1
2
3
4


             
                                                            




























                                                                       
                        






                                                        

                                  
                                 
 





                                                  



                                          
                           


                                                                                
                                                                                
                                                                                
 


                                                                                                                             
                                                                                                     
 

                                                         
                                  
 
                                   


                                



                                                                                                            
/*
 * mock_log.c
 *
 * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
 *
 * This file is part of Profanity.
 *
 * Profanity is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Profanity is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Profanity.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <glib.h>
#include <setjmp.h>
#include <cmocka.h>

#include "log.h"

void log_init(log_level_t filter) {}
log_level_t log_get_filter(void)
{
    return (log_level_t)mock();
}
void log_reinit(void) {}
void log_close(void) {}
void log_debug(const char * const msg, ...) {}
void log_info(const char * const msg, ...) {}
void log_warning(const char * const msg, ...) {}
void log_error(const char * const msg, ...) {}
void log_msg(log_level_t level, const char * const area,
    const char * const msg) {}
char * get_log_file_location(void)
{
    return mock_ptr_type(char *);
}

log_level_t log_level_from_string(char *log_level)
{
    return (log_level_t)mock();
}

void log_stderr_init(log_level_t level) {}
void log_stderr_close(void) {}
void log_stderr_handler(void) {}

void chat_log_init(void) {}

void chat_log_msg_out(const char * const barejid, const char * const msg) {}
void chat_log_otr_msg_out(const char * const barejid, const char * const msg) {}
void chat_log_pgp_msg_out(const char * const barejid, const char * const msg) {}
void chat_log_omemo_msg_out(const char *const barejid, const char *const msg) {}

void chat_log_msg_in(const char * const barejid, const char * const msg, GDateTime *timestamp) {}
void chat_log_otr_msg_in(const char * const barejid, const char * const msg, gboolean was_decrypted, GDateTime *timestamp) {}
void chat_log_pgp_msg_in(const char * const barejid, const char * const msg, GDateTime *timestamp) {}
void chat_log_omemo_msg_in(const char *const barejid, const char *const msg, GDateTime *timestamp) {}

void chat_log_close(void) {}
GSList * chat_log_get_previous(const gchar * const login,
    const gchar * const recipient)
{
    return mock_ptr_type(GSList *);
}

void groupchat_log_init(void) {}
void groupchat_log_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) {}
void groupchat_log_msg_out(const gchar *const room, const gchar *const msg) {}
void groupchat_log_omemo_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) {}
void groupchat_log_omemo_msg_out(const gchar *const room, const gchar *const msg) {}
class="nx">Name) case *types.Done: // There is always an INBOX, RFC-guaranteed // However, for some reason Dovecot doesn't always send it. inbox := false for _, dir := range dirs { if dir == "INBOX" { inbox = true } } if !inbox { dirs = append(dirs, "INBOX") } sort.Strings(dirs) dirlist.dirs = dirs dirlist.spinner.Stop() dirlist.Invalidate() if done != nil { done(dirs) } } }) } func (dirlist *DirectoryList) Select(name string) { dirlist.selecting = name dirlist.worker.PostAction(&types.OpenDirectory{Directory: name}, func(msg types.WorkerMessage) { switch msg.(type) { case *types.Error: dirlist.selecting = "" case *types.Done: dirlist.selected = dirlist.selecting } dirlist.Invalidate() }) dirlist.Invalidate() } func (dirlist *DirectoryList) Selected() string { return dirlist.selected } func (dirlist *DirectoryList) Invalidate() { dirlist.DoInvalidate(dirlist) } func (dirlist *DirectoryList) Draw(ctx *ui.Context) { ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault) if dirlist.spinner.IsRunning() { dirlist.spinner.Draw(ctx) return } row := 0 for _, name := range dirlist.dirs { if row >= ctx.Height() { break } if len(dirlist.conf.Folders) > 1 && name != dirlist.selected { idx := sort.SearchStrings(dirlist.conf.Folders, name) if idx == len(dirlist.conf.Folders) || dirlist.conf.Folders[idx] != name { continue } } style := tcell.StyleDefault if name == dirlist.selected { style = style.Reverse(true) } ctx.Fill(0, row, ctx.Width(), 1, ' ', style) ctx.Printf(0, row, style, "%s", name) row++ } } func (dirlist *DirectoryList) nextPrev(delta int) { for i, dir := range dirlist.dirs { if dir == dirlist.selected { var j int ndirs := len(dirlist.dirs) for j = i + delta; j != i; j += delta { if j < 0 { j = ndirs - 1 } if j >= ndirs { j = 0 } name := dirlist.dirs[j] if len(dirlist.conf.Folders) > 1 && name != dirlist.selected { idx := sort.SearchStrings(dirlist.conf.Folders, name) if idx == len(dirlist.conf.Folders) || dirlist.conf.Folders[idx] != name { continue } } break } dirlist.Select(dirlist.dirs[j]) break } } } func (dirlist *DirectoryList) Next() { dirlist.nextPrev(1) } func (dirlist *DirectoryList) Prev() { dirlist.nextPrev(-1) }